git-codereview: add mail -trybot flag

This flag sets the Run-TryBot+1 label when uploading a CL.

Change-Id: I46d14733e0d23c8f40198b0bf670c266ef05db16
Reviewed-on: https://go-review.googlesource.com/17053
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/git-codereview/mail.go b/git-codereview/mail.go
index 4a2b973..0354836 100644
--- a/git-codereview/mail.go
+++ b/git-codereview/mail.go
@@ -17,6 +17,7 @@
 		diff   = flags.Bool("diff", false, "show change commit diff and don't upload or mail")
 		force  = flags.Bool("f", false, "mail even if there are staged changes")
 		topic  = flags.String("topic", "", "set Gerrit topic")
+		trybot = flags.Bool("trybot", false, "run trybots on the uploaded CLs")
 		rList  = new(stringList) // installed below
 		ccList = new(stringList) // installed below
 	)
@@ -24,7 +25,7 @@
 	flags.Var(ccList, "cc", "comma-separated list of people to CC:")
 
 	flags.Usage = func() {
-		fmt.Fprintf(stderr(), "Usage: %s mail %s [-r reviewer,...] [-cc mail,...] [-topic topic] [commit-hash]\n", os.Args[0], globalFlags)
+		fmt.Fprintf(stderr(), "Usage: %s mail %s [-r reviewer,...] [-cc mail,...] [-topic topic] [-trybot] [commit-hash]\n", os.Args[0], globalFlags)
 	}
 	flags.Parse(args)
 	if len(flags.Args()) > 1 {
@@ -72,6 +73,11 @@
 			dief("topic may not contain a comma")
 		}
 		refSpec += start + "topic=" + *topic
+		start = ","
+	}
+	if *trybot {
+		refSpec += start + "l=Run-TryBot"
+		start = ","
 	}
 	run("git", "push", "-q", "origin", refSpec)