]> git.corax.cc Git - toolbox/commitdiff
include/git: Add git_remote_get() function
authorMatthias Kruk <m@m10k.eu>
Fri, 7 Jan 2022 13:37:00 +0000 (22:37 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 7 Jan 2022 13:37:00 +0000 (22:37 +0900)
This commit adds the git_remote_get() function, which can be used to
determine the URLs of a repository's remotes.

include/git.sh

index 7e4c0c13ad6f8a9982910ae72d5751336d38612e..a458ccf020dfa34dc500fcf3d4c66bc1f2fd55f3 100644 (file)
@@ -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
+}