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
5555const mrSelect = `
5656 SELECT m.id, m.repo_id, m.number, u.username,
5757 COALESCE(m.source_repo_id, 0),
58 COALESCE(su.username || '/' || sr.name, ''),
58 COALESCE(COALESCE(su.username, so.name) || '/' || sr.name, ''),
5959 m.source_ref, m.target_ref, m.title, m.body, m.state, m.head_sha,
6060 m.created_at, m.updated_at
6161 FROM merge_requests m
6262 JOIN users u ON u.id = m.author_id
6363 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`
6566
6667func scanMR(row interface{ Scan(...any) error }) (MR, error) {
6768 var m MR