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 <bradfitz@golang.org>
diff --git a/cmd/gopherbot/gopherbot.go b/cmd/gopherbot/gopherbot.go
index a4fffd5..6f404b0 100644
--- a/cmd/gopherbot/gopherbot.go
+++ b/cmd/gopherbot/gopherbot.go
@@ -1136,7 +1136,7 @@
 			// the last time the "wait-author" tag was
 			// added.
 			if tags.Contains("wait-author") {
-				// Figure out othe last index at which "wait-author" was added.
+				// Figure out the last index at which "wait-author" was added.
 				waitAuthorIndex := -1
 				for i := len(cl.Metas) - 1; i >= 0; i-- {
 					if cl.Metas[i].HashtagsAdded().Contains("wait-author") {
@@ -1145,17 +1145,17 @@
 					}
 				}
 
-				// Find the author has replied since
-				author := cl.Metas[0].Commit.Author.Str
+				// Find out whether the author has replied since.
+				authorEmail := cl.Metas[0].Commit.Author.Email() // Equivalent to "{{cl.OwnerID}}@62eb7196-b449-3ce5-99f1-c037f21e1705".
 				hasReplied := false
 				for _, m := range cl.Metas[waitAuthorIndex+1:] {
-					if m.Commit.Author.Str == author {
+					if m.Commit.Author.Email() == authorEmail {
 						hasReplied = true
 						break
 					}
 				}
 				if hasReplied {
-					log.Printf("https://golang.org/cl/%d -- remove wait-author; reply from %s", cl.Number, author)
+					log.Printf("https://golang.org/cl/%d -- remove wait-author; reply from %s", cl.Number, cl.Owner())
 					err := b.onLatestCL(ctx, cl, func() error {
 						if *dryRun {
 							log.Printf("[dry run] would remove hashtag 'wait-author' from CL %d", cl.Number)
diff --git a/maintner/git.go b/maintner/git.go
index 3d67010..e663304 100644
--- a/maintner/git.go
+++ b/maintner/git.go
@@ -161,6 +161,9 @@
 	return strings.TrimSpace(p.Str[:i])
 }
 
+// String implements fmt.Stringer.
+func (p *GitPerson) String() string { return p.Str }
+
 // requires c.mu be held for writing.
 func (c *Corpus) enqueueCommitLocked(h GitHash) {
 	if _, ok := c.gitCommit[h]; ok {