Skip to content

Commit 5d2b366

Browse files
committed
cmd/gopherbot: compare Gerrit users by email only
maintner represents Gerrit users via its underlying low-level git author representation, such as: Foo Bar <GerritUserID@GerritServerID> The server ID represents the Gerrit instance and doesn't change. The user ID uniquely identifies a Gerrit user on the Gerrit instance. However, Gerrit is not consistent about the name it uses. Sometimes it's the actual name, but other times it's "Gerrit User <NumericID>". For example, both of these forms come up: Dmitri Shuralyov <6005@62eb7196-b449-3ce5-99f1-c037f21e1705> Gerrit User 6005 <6005@62eb7196-b449-3ce5-99f1-c037f21e1705> Fix the author comparison logic in unwaitCLs task by comparing only the git email of Gerrit users. Fixes golang/go#30172 Change-Id: Ib193de844ecc6212723344765fc920bc08d906a4 Reviewed-on: https://go-review.googlesource.com/c/161977 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 05a16de commit 5d2b366

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

cmd/gopherbot/gopherbot.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ func (b *gopherbot) unwaitCLs(ctx context.Context) error {
11361136
// the last time the "wait-author" tag was
11371137
// added.
11381138
if tags.Contains("wait-author") {
1139-
// Figure out othe last index at which "wait-author" was added.
1139+
// Figure out the last index at which "wait-author" was added.
11401140
waitAuthorIndex := -1
11411141
for i := len(cl.Metas) - 1; i >= 0; i-- {
11421142
if cl.Metas[i].HashtagsAdded().Contains("wait-author") {
@@ -1145,17 +1145,17 @@ func (b *gopherbot) unwaitCLs(ctx context.Context) error {
11451145
}
11461146
}
11471147

1148-
// Find the author has replied since
1149-
author := cl.Metas[0].Commit.Author.Str
1148+
// Find out whether the author has replied since.
1149+
authorEmail := cl.Metas[0].Commit.Author.Email() // Equivalent to "{{cl.OwnerID}}@62eb7196-b449-3ce5-99f1-c037f21e1705".
11501150
hasReplied := false
11511151
for _, m := range cl.Metas[waitAuthorIndex+1:] {
1152-
if m.Commit.Author.Str == author {
1152+
if m.Commit.Author.Email() == authorEmail {
11531153
hasReplied = true
11541154
break
11551155
}
11561156
}
11571157
if hasReplied {
1158-
log.Printf("https://golang.org/cl/%d -- remove wait-author; reply from %s", cl.Number, author)
1158+
log.Printf("https://golang.org/cl/%d -- remove wait-author; reply from %s", cl.Number, cl.Owner())
11591159
err := b.onLatestCL(ctx, cl, func() error {
11601160
if *dryRun {
11611161
log.Printf("[dry run] would remove hashtag 'wait-author' from CL %d", cl.Number)

maintner/git.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ func (p *GitPerson) Name() string {
161161
return strings.TrimSpace(p.Str[:i])
162162
}
163163

164+
// String implements fmt.Stringer.
165+
func (p *GitPerson) String() string { return p.Str }
166+
164167
// requires c.mu be held for writing.
165168
func (c *Corpus) enqueueCommitLocked(h GitHash) {
166169
if _, ok := c.gitCommit[h]; ok {

0 commit comments

Comments
 (0)