experimental/documentation/gerrit.md: improvements
authorHal Canary <halcanary@google.com>
Mon, 30 Jan 2017 17:27:14 +0000 (12:27 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 30 Jan 2017 17:47:31 +0000 (17:47 +0000)
https://skia.googlesource.com/skia/+/master/experimental/documentation/gerrit.md
NOTRY=true
Change-Id: I90d8e16e9d6146fefe0199bb98d5f8eea31d4e8f
Reviewed-on: https://skia-review.googlesource.com/7750
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>

experimental/documentation/gerrit.md
experimental/tools/setup-gerrit [new file with mode: 0644]

index e30458b..4a6b2db 100644 (file)
@@ -4,16 +4,11 @@ Using Gerrit without git-cl
 setup
 -----
 
-    cd ...skia_source_dir...
+<pre class="code"><code>
+cd ...skia_source_dir...
 
-    curl -Lo .git/hooks/commit-msg \
-      https://skia-review.googlesource.com/tools/hooks/commit-msg
-
-    chmod +x .git/hooks/commit-msg
-
-    git remote set-url origin https://skia.googlesource.com/skia.git
-
-    git config branch.autosetuprebase always
+sh [experimental/tools/setup-gerrit](../tools/setup-gerrit)
+</code></pre>
 
 
 creating a change
@@ -32,13 +27,13 @@ creating a change
 
 3.  Squash the commits:
 
-        MSG="$(git log --format='%B' ^@{u} @)"
-        git reset --soft $(git merge-base @ @{u})
-        git commit -m "$MSG" -e
+        git squash-commits
+
+    This is only needed if you have more than one commit on your branch.
 
 4.  Push to Gerrit
 
-        git push origin @:refs/for/master%cc=reviews@skia.org
+        git gerrit-push-master
 
 
 updating a change
@@ -48,12 +43,15 @@ updating a change
 1.  Edit your commits more.
 
         echo 3 > whitespace.txt
-        git commit -a --amend --reuse-message=@
+        git amend-head
+
+2.  Re-squash if needed.  (Not needed if you only amended your original commit.)
+
 
-2.  Re-squash if needed.
+3.  Push to Gerrit.
 
+        git gerrit-push-master this is a message
 
-3.  Push to Gerrit
+    The title of this patchset will be "this is a message".
 
-        git push origin @:refs/for/master%m=this_is_a_message
 
diff --git a/experimental/tools/setup-gerrit b/experimental/tools/setup-gerrit
new file mode 100644 (file)
index 0000000..be372b6
--- /dev/null
@@ -0,0 +1,44 @@
+#! /bin/sh
+
+# Copyright 2017 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -x
+set -e
+
+cd "$(dirname "$0")/../.."
+
+
+### Configure the Change-Id commit-msg Git hook
+
+commit_message_path="$(git rev-parse --git-dir)/hooks/commit-msg"
+
+curl -Lo "$commit_message_path" \
+  'https://gerrit-review.googlesource.com/tools/hooks/commit-msg'
+
+chmod +x "$commit_message_path"
+
+### Verify that origin points at the canonical origin, not github
+
+git remote set-url origin 'https://skia.googlesource.com/skia.git'
+
+### Skia uses a linear history, so rebase-on-pull is a good idea
+
+git config branch.autoSetupRebase 'always'
+
+### this  alias does the heavy lifting of talking to gerrit
+
+git config alias.gerrit-push-master \
+  '!f() { git push origin @:refs/for/master%m=$(echo "$*"|sed "s/[^a-zA-Z0-9]/_/g");};f'
+
+### this alias ensures that your branch has ony one commit on it
+
+git config alias.squash-commits \
+    '!MSG="$(git log --format=%B ^@{u} @)";git reset --soft $(git merge-base @ @{u});git commit -m "$MSG" -e'
+
+### Amend the HEAD head commit without changing the commit message
+
+git config alias.amend-head 'commit --all --amend --reuse-message=@'
+