]> git.wh0rd.org - home.git/commitdiff
smarter gerrit push
authorMike Frysinger <vapier@gentoo.org>
Tue, 14 Aug 2012 21:16:31 +0000 (17:16 -0400)
committerMike Frysinger <vapier@gentoo.org>
Tue, 14 Aug 2012 21:16:31 +0000 (17:16 -0400)
.bin/r

diff --git a/.bin/r b/.bin/r
index d350c882b0d5dbe86acbd44ec2b167b59c6795e4..6496e1d6c3db4613a434e7d42ac876cb9b106308 100755 (executable)
--- a/.bin/r
+++ b/.bin/r
@@ -1,6 +1,7 @@
 #!/bin/bash
 g() { git "$@"; }
 err() { printf '%b\n' "$*" 1>&2; exit 1; }
+vr() { echo "$@"; "$@"; }
 
 case $1 in
 ""|-*) ;;
@@ -107,7 +108,22 @@ sb-push)
        ;;
 g-push)
        # For the times when repo is being stupid, push directly to gerrit myself.
-       exec git push origin HEAD:refs/for/master
+       if ! branch=$(g symbolic-ref -q HEAD) ; then
+               err "could not figure out active branch"
+       fi
+       branch=${branch#refs/heads/}
+       if ! remote_branch=$(g cfg --get "branch.${branch}.merge") ; then
+               err "could not figure out remote branch"
+       fi
+       remote_branch=${remote_branch#refs/heads/}
+
+       for remote in cros-internal cros origin ; do
+               if g cfg --get "remote.${remote}.url" >/dev/null ; then
+                       vr git push ${remote} ${branch}:refs/for/${remote_branch}
+                       exit $?
+               fi
+       done
+       err "could not figure out remote to push to"
        ;;
 sync)
        [[ $# -eq 0 ]] && set -- -j16