experimental/documentation/gerrit.md: check for error case

NOTRY=true
Change-Id: I0eebe482111efa90dc2fb9d106bdacaf689a38d3
Reviewed-on: https://skia-review.googlesource.com/21371
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2017-07-02 12:38:45 -04:00 committed by Skia Commit-Bot
parent 6feb69123b
commit f642cb337a

View File

@ -126,14 +126,20 @@ If your branch's upstream branch (set with `git branch --set-upstream-to=...`)
is set, you can use that to automatically push to that branch:
gerrit_push_upstream() {
local UPSTREAM="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})"
local UPSTREAM_FULL="$(git rev-parse --symbolic-full-name @{upstream})"
case "$UPSTREAM_FULL" in
(refs/remotes/*) :;;
(*) echo "Set your remote upstream branch."; return 2;;
esac
local UPSTREAM="${UPSTREAM_FULL#refs/remotes/}"
local REMOTE="${UPSTREAM%%/*}"
local REMOTE_BRANCH="${UPSTREAM#*/}"
local MESSAGE="$(echo $*|sed 's/[^A-Za-z0-9]/_/g')"
echo git push $R @:refs/for/${B}%m=${M};
git push "$REMOTE" "@:refs/for/${REMOTE_BRANCH}%m=${MESSAGE}"
}
As a Git alias:
git config alias.gerrit-push-upstream '!f()(U="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})";R="${U%%/*}";B="${U#*/}";M="$(echo $*|sed 's/[^A-Za-z0-9]/_/g')";git push "$R" "@:refs/for/${B}%m=$M");f'
git config alias.gerrit-push '!f()(F="$(git rev-parse --symbolic-full-name @{u})";case "$F" in (refs/remotes/*);;(*)echo "Set your remote upstream branch.";return 2;;esac;U="${F#refs/remotes/}";R="${U%%/*}";B="${U#*/}";M="$(echo $*|sed 's/[^A-Za-z0-9]/_/g')";echo git push $R @:refs/for/${B}%m=$M;git push "$R" "@:refs/for/${B}%m=$M");f'