From 2c00c71989b10b0e65e946804ea6bdedf8545048 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Fri, 7 Jan 2022 22:37:00 +0900 Subject: [PATCH] include/git: Add git_remote_get() function This commit adds the git_remote_get() function, which can be used to determine the URLs of a repository's remotes. --- include/git.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/git.sh b/include/git.sh index 7e4c0c1..a458ccf 100644 --- a/include/git.sh +++ b/include/git.sh @@ -165,3 +165,18 @@ git_commit() { return 0 } + +git_remote_get() { + local repository="$1" + local remote="$2" + + local url + + if ! url=$(cd "$repository" && git remote get-url "$remote"); then + log_error "Could not get URL of remote $remote in $repository" + return 1 + fi + + echo "$url" + return 0 +} -- 2.47.3