aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-05-15 16:16:42 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-15 20:21:36 +0000
commitcbd0f3b4e3239ffd84402ed63a85e88e484a4c47 (patch)
tree5546a48041be4d5711fd19214460f613cd9ee688
parent35a87d60e6e6234a13808a67be832140035bab4e (diff)
experimental/documentation/gerrit.md: more tricks
NOTRY=true Change-Id: I04d371b16f7805b4c972010a5bc1eebd979169a6 Reviewed-on: https://skia-review.googlesource.com/16915 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
-rw-r--r--experimental/documentation/gerrit.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/experimental/documentation/gerrit.md b/experimental/documentation/gerrit.md
index e3aa775b49..7767c8c358 100644
--- a/experimental/documentation/gerrit.md
+++ b/experimental/documentation/gerrit.md
@@ -122,4 +122,18 @@ These shell scripts can be turned into Git aliases with a little hack:
git config alias.gerrit-push-message '!f(){ git push origin @:refs/for/master%m=$(echo $*|sed "s/[^A-Za-z0-9]/_/g");};f'
+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 REMOTE="${UPSTREAM%%/*}"
+ local REMOTE_BRANCH="${UPSTREAM#*/}"
+ local MESSAGE="$(echo $*|sed 's/[^A-Za-z0-9]/_/g')"
+ 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'