Commit a3aaeec269

a3aaeec2690ba7a3db89f27f0fb7e08fb90bc628

parent: 4485496a07

Verified · cmc

cmc <hello@cleberg.net> · 2026-08-24 03:10 UTC

mrs: resolve org-owned source repo names

The MR query joined users only for the source owner, so MRs sourced
from org-owned repos displayed an empty source path.

Layout: unified · split

internal/store/mrs.go +3 −2
@@ -55,13 +55,14 @@ func (s *Store) CreateMR(repoID, authorID, sourceRepoID int64, sourceRef, target
55const mrSelect = ` 55const mrSelect = `
56 SELECT m.id, m.repo_id, m.number, u.username, 56 SELECT m.id, m.repo_id, m.number, u.username,
57 COALESCE(m.source_repo_id, 0), 57 COALESCE(m.source_repo_id, 0),
58 COALESCE(su.username || '/' || sr.name, ''), 58 COALESCE(COALESCE(su.username, so.name) || '/' || sr.name, ''),
59 m.source_ref, m.target_ref, m.title, m.body, m.state, m.head_sha, 59 m.source_ref, m.target_ref, m.title, m.body, m.state, m.head_sha,
60 m.created_at, m.updated_at 60 m.created_at, m.updated_at
61 FROM merge_requests m 61 FROM merge_requests m
62 JOIN users u ON u.id = m.author_id 62 JOIN users u ON u.id = m.author_id
63 LEFT JOIN repos sr ON sr.id = m.source_repo_id 63 LEFT JOIN repos sr ON sr.id = m.source_repo_id
64 LEFT JOIN users su ON sr.owner_kind = 'user' AND su.id = sr.owner_id` 64 LEFT JOIN users su ON sr.owner_kind = 'user' AND su.id = sr.owner_id
65 LEFT JOIN orgs so ON sr.owner_kind = 'org' AND so.id = sr.owner_id`
65 66
66func scanMR(row interface{ Scan(...any) error }) (MR, error) { 67func scanMR(row interface{ Scan(...any) error }) (MR, error) {
67 var m MR 68 var m MR