\n"), 0o644)
mustGit(t, dir, env, "add", ".mailmap")
mustGit(t, dir, as("Alice", "alice@example.test"), "commit", "-q", "-m", "mailmap")
commits := []struct{ name, email string }{
{"Alice", "alice@example.test"},
{"Alice", "alice@example.test"},
{"A. Cleberg", "alice2@example.test"}, // verified here, not in the mailmap
{"A. Cleberg", "alice2@example.test"},
{"Alice Old", "alice@old.test"}, // in the mailmap, no account
{"Alice Old", "alice@old.test"},
{"Pat", "pat1@example.test"}, // same name, different people
{"Pat", "pat2@example.test"},
}
for i, c := range commits {
mustGit(t, dir, as(c.name, c.email),
"commit", "-q", "--allow-empty", "-m", strconv.Itoa(i))
}
mustGit(t, dir, env, "push", "-q", "origin", "main")
status, body := inst.get(t, "/alice/ident")
if status != 200 {
t.Fatalf("repo home: %d", status)
}
// Scope the positives to the contributors bar: the tip bar names an
// author too, and links it to the same profile.
_, contribs, ok := strings.Cut(body, ``)
if !ok {
t.Fatal("no contributors bar")
}
contribs, _, _ = strings.Cut(contribs, "
")
for _, want := range []string{
"3 contributors",
// Three addresses, one account, one row, named by the account.
`title="alice@example.test · 7 commits">alice`,
// One commit is one commit.
`title="pat1@example.test · 1 commit"`,
`title="pat2@example.test · 1 commit"`,
} {
if !strings.Contains(contribs, want) {
t.Errorf("contributors bar missing %q", want)
}
}
if n := strings.Count(contribs, `href="/alice"`); n != 1 {
t.Errorf("account listed as %d contributors, want 1", n)
}
for _, gone := range []string{"alice@old.test", "alice2@example.test", "A. Cleberg", "Alice Old"} {
if strings.Contains(body, gone) {
t.Errorf("collapsed identity %q still shown", gone)
}
}
}