From: Mike Frysinger Date: Tue, 14 Aug 2012 21:16:31 +0000 (-0400) Subject: smarter gerrit push X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e3be888977bf6d6bc80be73369657ed1dc88eb2a;p=home.git smarter gerrit push --- 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