aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/hook_test.go
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2019-03-25 11:35:57 +1100
committerAndrew Gerrand <adg@golang.org>2019-03-25 02:02:52 +0000
commit7744f6d7ac193720bb483dc2a2c266504b33d1a9 (patch)
treeee8009a5598eaa5798124ef09af58f12fad81ab4 /git-codereview/hook_test.go
parent05c26900aa9101b5ab40490ad329fab7dfa56cb6 (diff)
downloadgo-x-review-7744f6d7ac193720bb483dc2a2c266504b33d1a9.tar.xz
git-codereview: make commit-msg hook play nicely with other systems
Gerrit requires 'Change-Id:' lines to be included in each commit message, but they are not the only kind of 'metadata line' that might appear in a commit message. Metadata lines observed by other systems include 'Bug:' and 'Signed-off-by:'. This change ensures that the commit-msg hook adds its 'Change-Id:' line to the set of metadata lines, separated only by a single linefeed, rather than creating a new set by inserting two line feeds. Change-Id: Ia3bdce6f52f663685eea1e648874ef81ddb2bd91 Reviewed-on: https://go-review.googlesource.com/c/review/+/169097 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'git-codereview/hook_test.go')
-rw-r--r--git-codereview/hook_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/git-codereview/hook_test.go b/git-codereview/hook_test.go
index 8cb04f9..d1cc0c6 100644
--- a/git-codereview/hook_test.go
+++ b/git-codereview/hook_test.go
@@ -42,6 +42,16 @@ func TestHookCommitMsgGerrit(t *testing.T) {
if got := testStderr.String(); got != multiple {
t.Fatalf("unexpected output:\ngot: %q\nwant: %q", got, multiple)
}
+
+ // Check that hook doesn't add two line feeds before Change-Id
+ // if the exsting message ends with a metadata line.
+ write(t, gt.client+"/msg.txt", "Test message.\n\nBug: 1234\n")
+ testMain(t, "hook-invoke", "commit-msg", gt.client+"/msg.txt")
+ data = read(t, gt.client+"/msg.txt")
+ if !bytes.Contains(data, []byte("Bug: 1234\nChange-Id: ")) {
+ t.Fatalf("after hook-invoke commit-msg, missing Change-Id: directly after Bug line\n%s", data)
+ }
+
}
func TestHookCommitMsg(t *testing.T) {