diff options
| -rw-r--r-- | git-codereview/mail.go | 8 | ||||
| -rw-r--r-- | git-codereview/mail_test.go | 13 |
2 files changed, 20 insertions, 1 deletions
diff --git a/git-codereview/mail.go b/git-codereview/mail.go index c9bb567..5d385f9 100644 --- a/git-codereview/mail.go +++ b/git-codereview/mail.go @@ -254,13 +254,19 @@ func mailLookup(short string) string { short += "@" for _, r := range reviewers { - if strings.HasPrefix(r.addr, short) { + if strings.HasPrefix(r.addr, short) && !shortOptOut[r.addr] { return r.addr } } return "" } +// shortOptOut lists email addresses whose owners have opted out +// from consideration for purposes of expanding short user names. +var shortOptOut = map[string]bool{ + "dmitshur@google.com": true, // My @golang.org is primary; @google.com is used for +1 only. +} + // loadReviewers reads the reviewer list from the current git repo // and leaves it in the global variable reviewers. // See the comment on mailLookup for a description of how the diff --git a/git-codereview/mail_test.go b/git-codereview/mail_test.go index a376ea3..d3ef181 100644 --- a/git-codereview/mail_test.go +++ b/git-codereview/mail_test.go @@ -181,6 +181,10 @@ var reviewerLog = []string{ "Reviewer 1 <r1@golang.org>", "Other <other@golang.org>", "<anon@golang.org>", + "Reviewer 2 <r2@new.example>", + "Reviewer 2 <r2@old.example>", + "Reviewer 2 <r2@old.example>", + "Reviewer 2 <r2@old.example>", } func TestMailShort(t *testing.T) { @@ -226,6 +230,15 @@ func TestMailShort(t *testing.T) { testMainDied(t, "mail", "-r", "other", "-r", "anon,r1,missing") testPrintedStderr(t, "unknown reviewer: missing") + + // Test shortOptOut. + orig := shortOptOut + defer func() { shortOptOut = orig }() + shortOptOut = map[string]bool{"r2@old.example": true} + testMain(t, "mail", "-r", "r2") + testRan(t, + "git push -q origin HEAD:refs/for/main%r=r2@new.example", + "git tag --no-sign -f work.mailed "+h) } func TestWIP(t *testing.T) { |
