From e3be888977bf6d6bc80be73369657ed1dc88eb2a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 14 Aug 2012 17:16:31 -0400 Subject: [PATCH] smarter gerrit push --- .bin/r | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.bin/r b/.bin/r index d350c88..6496e1d 100755 --- 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 -- 2.39.5