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 <tobias.klauser@gmail.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
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 @@
 	// 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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",
 	)
 }