Commit c074c8aa48

c074c8aa4896cf328001dc7ef83eccac2147c6c4

parent: 478bd0c00c

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-12 05:06 UTC

control, web: the close event reads closed by <who> in commit <sha>

Ref #182

Layout: unified · split

e2e/commitrefs_test.go +7 −6
@@ -41,7 +41,7 @@ func TestCommitMessageIssueActions(t *testing.T) {
41 mustGit(t, dir, env, "push", "-q", "origin", "main") 41 mustGit(t, dir, env, "push", "-q", "origin", "main")
42 42
43 out, _, _ := inst.ssh(t, aliceKey, "", "issue", "show", "alice/app", "1", "--json") 43 out, _, _ := inst.ssh(t, aliceKey, "", "issue", "show", "alice/app", "1", "--json")
44 if !strings.Contains(out, `"state":"closed"`) || !strings.Contains(out, "closed by commit") { 44 if !strings.Contains(out, `"state":"closed"`) || !strings.Contains(out, "closed by ") {
45 t.Fatalf("issue 1 not closed by commit: %s", out) 45 t.Fatalf("issue 1 not closed by commit: %s", out)
46 } 46 }
47 // The entry is a system message with a linked sha, not a user comment. 47 // The entry is a system message with a linked sha, not a user comment.
@@ -86,15 +86,15 @@ func TestCommitMessageIssueActions(t *testing.T) {
86 t.Fatalf("merge: %s", errOut) 86 t.Fatalf("merge: %s", errOut)
87 } 87 }
88 out, _, _ = inst.ssh(t, aliceKey, "", "issue", "show", "alice/app", "3", "--json") 88 out, _, _ = inst.ssh(t, aliceKey, "", "issue", "show", "alice/app", "3", "--json")
89 if !strings.Contains(out, `"state":"closed"`) || !strings.Contains(out, "closed by commit") { 89 if !strings.Contains(out, `"state":"closed"`) || !strings.Contains(out, "closed by ") {
90 t.Fatalf("merge did not close issue 3: %s", out) 90 t.Fatalf("merge did not close issue 3: %s", out)
91 } 91 }
92 // This one was authored by an address nobody has verified, so it names 92 // This one was authored by an address nobody has verified, so it names
93 // git's author without inventing a profile link for them. 93 // git's author without inventing a profile link for them.
94 if !strings.Contains(out, "by t:") || strings.Contains(out, "by [t]") { 94 if !strings.Contains(out, "closed by t in commit") || strings.Contains(out, "closed by [t]") {
95 t.Fatalf("unresolved author should stay plain text: %s", out) 95 t.Fatalf("unresolved author should stay plain text: %s", out)
96 } 96 }
97 if strings.Count(out, "closed by commit") != 1 { 97 if strings.Count(out, "closed by ") != 1 {
98 t.Fatalf("duplicate close comments: %s", out) 98 t.Fatalf("duplicate close comments: %s", out)
99 } 99 }
100 100
@@ -126,8 +126,9 @@ func TestCommitMessageIssueActions(t *testing.T) {
126 t.Fatalf("commit-file: %s", errOut) 126 t.Fatalf("commit-file: %s", errOut)
127 } 127 }
128 out, _, _ = inst.ssh(t, aliceKey, "", "issue", "show", "alice/app", "2", "--json") 128 out, _, _ = inst.ssh(t, aliceKey, "", "issue", "show", "alice/app", "2", "--json")
129 if !strings.Contains(out, `"state":"closed"`) || !strings.Contains(out, "closed by commit") || 129 if !strings.Contains(out, `"state":"closed"`) ||
130 !strings.Contains(out, "by [alice](/alice): Closes #2 from the editor") { 130 !strings.Contains(out, "closed by [alice](/alice) in commit") ||
131 !strings.Contains(out, ": Closes #2 from the editor") {
131 t.Fatalf("commit-file did not close issue 2: %s", out) 132 t.Fatalf("commit-file did not close issue 2: %s", out)
132 } 133 }
133 if strings.Count(out, "referenced in commit") != 1 { 134 if strings.Count(out, "referenced in commit") != 1 {
internal/control/commitrefs.go +1 −1
@@ -240,7 +240,7 @@ func actOnIssue(st *store.Store, source, target store.Repo, actorID int64, sha s
240 slog.Error("commit refs: closing issue", "issue", number, "err", err) 240 slog.Error("commit refs: closing issue", "issue", number, "err", err)
241 return 241 return
242 } 242 }
243 st.AddIssueSystemComment(issue.ID, actorID, fmt.Sprintf("closed by commit %s by %s: %s", link, author, subject)) 243 st.AddIssueSystemComment(issue.ID, actorID, fmt.Sprintf("closed by %s in commit %s: %s", author, link, subject))
244 st.RecordEvent(target.ID, actorID, "issue.closed", fmt.Sprintf(`{"number":%d,"sha":%q}`, number, sha)) 244 st.RecordEvent(target.ID, actorID, "issue.closed", fmt.Sprintf(`{"number":%d,"sha":%q}`, number, sha))
245 return 245 return
246 } 246 }