Skip to content

Commit fada1f3

Browse files
committed
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 <[email protected]>
1 parent 5df336c commit fada1f3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/gerritbot/gerritbot.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,17 @@ func (b *bot) importGerritChangeFromPR(ctx context.Context, pr *github.PullReque
609609
}
610610
}
611611

612+
var pushOpts string
613+
if cl == nil {
614+
// Add this informational message only on CL creation.
615+
msg := fmt.Sprintf("This Gerrit CL corresponds to GitHub PR %s.\n\nAuthor: %s", prShortLink(pr), author)
616+
pushOpts = "%m=" + url.QueryEscape(msg)
617+
}
618+
612619
// nokeycheck is specified to avoid failing silently when a review is created
613620
// with what appears to be a private key. Since there are cases where a user
614621
// would want a private key checked in (tests).
615-
out, err := cmdOut(exec.Command("git", "-C", worktreeDir, "push", "-o", "nokeycheck", "origin", "HEAD:refs/for/"+prBaseRef))
622+
out, err := cmdOut(exec.Command("git", "-C", worktreeDir, "push", "-o", "nokeycheck", "origin", "HEAD:refs/for/"+prBaseRef+pushOpts))
616623
if err != nil {
617624
return fmt.Errorf("could not create change: %v", err)
618625
}

0 commit comments

Comments
 (0)