cmd/gerritbot: add informational message upon initial upload of CL

In some cases (https://golang.org/cl/148477), the original author
of a change has not registered themselves with Gerrit. This causes
the change to assign Gobot as the owner, making it difficult to know
who originally authored the change. When initially creating the
Gerrit CL, upload some informational text that includes which GitHub
PR the CL corresponds to and who the author is according to git.

Fixes golang/go#28662

Change-Id: Icc8dad4e79d7270635b71b1e2cd24e0e1b8e5286
Reviewed-on: https://go-review.googlesource.com/c/148564
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/cmd/gerritbot/gerritbot.go b/cmd/gerritbot/gerritbot.go
index 0b9ff18..431f9eb 100644
--- a/cmd/gerritbot/gerritbot.go
+++ b/cmd/gerritbot/gerritbot.go
@@ -609,10 +609,17 @@
 		}
 	}
 
+	var pushOpts string
+	if cl == nil {
+		// Add this informational message only on CL creation.
+		msg := fmt.Sprintf("This Gerrit CL corresponds to GitHub PR %s.\n\nAuthor: %s", prShortLink(pr), author)
+		pushOpts = "%m=" + url.QueryEscape(msg)
+	}
+
 	// nokeycheck is specified to avoid failing silently when a review is created
 	// with what appears to be a private key. Since there are cases where a user
 	// would want a private key checked in (tests).
-	out, err := cmdOut(exec.Command("git", "-C", worktreeDir, "push", "-o", "nokeycheck", "origin", "HEAD:refs/for/"+prBaseRef))
+	out, err := cmdOut(exec.Command("git", "-C", worktreeDir, "push", "-o", "nokeycheck", "origin", "HEAD:refs/for/"+prBaseRef+pushOpts))
 	if err != nil {
 		return fmt.Errorf("could not create change: %v", err)
 	}