aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/documentation
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-07-02 12:38:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-02 16:46:20 +0000
commitf642cb337ae4bde590ec32ed683c6650aa124c6b (patch)
tree604dbe5f259eb55a96c1fce35c613d58bbf003d4 /experimental/documentation
parent6feb69123b11f0034e28232308d2034c3701d02d (diff)
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>
Diffstat (limited to 'experimental/documentation')
-rw-r--r--experimental/documentation/gerrit.md10
1 files changed, 8 insertions, 2 deletions
diff --git a/experimental/documentation/gerrit.md b/experimental/documentation/gerrit.md
index 7767c8c358..5a17f8a4c6 100644
--- a/experimental/documentation/gerrit.md
+++ b/experimental/documentation/gerrit.md
@@ -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'