From b8ead204a2e00eca3f1554da0b908d1d7b7afb9f Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 3 Dec 2021 20:11:11 +0100 Subject: git-codereview: don't sign git tags For users who set tag.gpgSign=true in their git configuration, git-codereview mail currently fails to create the .mailed git tag because a signed git tag always requires a message: fatal: no tag message? (running: git tag -f foobar.mailed cf87726ac456) /home/tklauser/go/bin/git-codereview: exit status 128 Fix this by overriding the tag.gpgSign configuration using git tag --no-sign. There is no point in having these tags signed as they should never leave the local system. Change-Id: I8b7ddf3aa7709e6ea06e4d5add6cd581e9ec2e37 Reviewed-on: https://go-review.googlesource.com/c/review/+/369194 Trust: Tobias Klauser Trust: Bryan Mills Run-TryBot: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- git-codereview/mail.go | 2 +- git-codereview/mail_test.go | 20 ++++++++++---------- git-codereview/sync_test.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/git-codereview/mail.go b/git-codereview/mail.go index b7fc9f9..2e6c6a6 100644 --- a/git-codereview/mail.go +++ b/git-codereview/mail.go @@ -169,7 +169,7 @@ func cmdMail(args []string) { // There is no conflict with the branch names people are using // for work, because git change rejects any name containing a dot. // The space of names with dots is ours (the Go team's) to define. - run("git", "tag", "-f", b.Name+".mailed", c.ShortHash) + run("git", "tag", "--no-sign", "-f", b.Name+".mailed", c.ShortHash) } // PushSpec returns the spec for a Gerrit push command to publish the change c in b. diff --git a/git-codereview/mail_test.go b/git-codereview/mail_test.go index 72fea82..a376ea3 100644 --- a/git-codereview/mail_test.go +++ b/git-codereview/mail_test.go @@ -29,7 +29,7 @@ func TestMail(t *testing.T) { testMain(t, "mail") testRan(t, "git push -q origin HEAD:refs/for/main", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) } func TestDoNotMail(t *testing.T) { @@ -160,14 +160,14 @@ func TestMailMultiple(t *testing.T) { testMain(t, "mail", "HEAD^") testRan(t, "git push -q origin "+h+":refs/for/main", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) // Mail HEAD. h = CurrentBranch().Pending()[0].ShortHash testMain(t, "mail", "HEAD") testRan(t, "git push -q origin HEAD:refs/for/main", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) } var reviewerLog = []string{ @@ -212,17 +212,17 @@ func TestMailShort(t *testing.T) { testMain(t, "mail") testRan(t, "git push -q origin HEAD:refs/for/main", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) testMain(t, "mail", "-r", "r1") testRan(t, "git push -q origin HEAD:refs/for/main%r=r1@golang.org", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) testMain(t, "mail", "-r", "other,anon", "-cc", "r1,full@email.com") testRan(t, "git push -q origin HEAD:refs/for/main%r=other@golang.org,r=anon@golang.org,cc=r1@golang.org,cc=full@email.com", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) testMainDied(t, "mail", "-r", "other", "-r", "anon,r1,missing") testPrintedStderr(t, "unknown reviewer: missing") @@ -238,7 +238,7 @@ func TestWIP(t *testing.T) { testMain(t, "mail", "-wip") testRan(t, "git push -q origin HEAD:refs/for/main%wip", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) } func TestMailTopic(t *testing.T) { @@ -264,7 +264,7 @@ func TestMailTopic(t *testing.T) { testMain(t, "mail", "-topic", "test-topic") testRan(t, "git push -q origin HEAD:refs/for/main%topic=test-topic", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) } func TestMailHashtag(t *testing.T) { @@ -287,11 +287,11 @@ func TestMailHashtag(t *testing.T) { testMain(t, "mail", "-hashtag", "test1,test2") testRan(t, "git push -q origin HEAD:refs/for/main%hashtag=test1,hashtag=test2", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) testMain(t, "mail", "-hashtag", "") testRan(t, "git push -q origin HEAD:refs/for/main", - "git tag -f work.mailed "+h) + "git tag --no-sign -f work.mailed "+h) testMainDied(t, "mail", "-hashtag", "test1,,test3") testPrintedStderr(t, "hashtag may not contain empty tags") diff --git a/git-codereview/sync_test.go b/git-codereview/sync_test.go index 0d3978d..6470c5e 100644 --- a/git-codereview/sync_test.go +++ b/git-codereview/sync_test.go @@ -315,7 +315,7 @@ func TestSyncBranchMergeBack(t *testing.T) { testNoStdout(t) testPrintedStderr(t, "git push -q origin HEAD:refs/for/main", - "git tag -f dev.branch.mailed", + "git tag --no-sign -f dev.branch.mailed", ) } @@ -393,6 +393,6 @@ func TestSyncBranchConflict(t *testing.T) { testNoStdout(t) testPrintedStderr(t, "git push -q origin HEAD:refs/for/dev.branch", - "git tag -f dev.branch.mailed", + "git tag --no-sign -f dev.branch.mailed", ) } -- cgit v1.3