╭ changed ──────╮ │src/ui/Repo.zig│ ╰───────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │47 const hash_kind = evt.admin_repo_opts.hash; │ │48 const haxy_moment = session.haxy_moment orelse return error.NoMoment; │ │49 │ │50 - // every repo route's stored string starts with "owner/name"; the files │ │51 - // route additionally encodes a directory, the commits route a start oid. │ │50 + // every repo route's stored string starts with "owner/name"; the files and│ │51 + // commits routes additionally encode a ref/oid (files also a directory). │ │52 const name_str: []const u8 = switch (route) { │ │53 .repo, .repo_settings, .repo_auth => |n| n.slice(), │ │54 .repo_commits => |c| c.name.slice(), │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │64 const files_ref_kind = if (tag == .repo) rf.ref_kind else null; │ │65 const files_ref_value = if (tag == .repo) rf.ref_value else ""; │ │66 const files_dir = if (tag == .repo) rf.dir else ""; │ │67 - const commits_start = if (tag == .repo_commits) ui.RoutablePage.repoCommitsStart(name_str) else ""; │ │67 + // a null commits ref means the commits tab opens at the default branch │ │68 + // (Commits.init resolves it). │ │69 + const commits_ref = if (tag == .repo_commits) ui.RoutablePage.repoCommitsRef(name_str) else ui.RoutablePage.CommitsRef{ .ref_or_oid = null, .value = "" };│ │70 // how many diff hunks the commits view's selected commit shows ("load more"). │ │71 const commits_after: usize = switch (route) { │ │72 .repo_commits => |c| c.after, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │89 // resolve the creating user so the header can show their name to the left │ │90 // of the repo title. │ │91 const owner = (try evt.User.readById(DB, hash_kind, haxy_moment, arena, repo.user_id)) orelse return error.NotFound; │ │92 + │ │93 + // build commits first so its resolved ref (the default branch when the route │ │94 + // named none) can canonicalize the commits-tab mirror url. │ │95 + const commits = try Commits.init(arena, session, &found.event_id, rf.identity, commits_ref.ref_or_oid, commits_ref.value, commits_after);│ │96 │ │97 // each tab mirror carries this page's route for that tab; tabs not targeted │ │98 // by the incoming route fall back to their root/first-page route. │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 99 const route_name = (ui.RoutablePage.repoFilesRoute(rf.identity, files_ref_kind, files_ref_value, files_dir) orelse return error.NotFound).repo; │ │ 94 - const commits_route_name = if (tag == .repo_commits) route.repo_commits.name else (ui.RoutablePage.repoCommitsRoute(rf.identity, "", 0) orelse return error.NotFound).repo_commits.name;│ │100 + const commits_route_name = (ui.RoutablePage.repoCommitsRoute(rf.identity, commits.ref_or_oid, commits.ref_or_oid_value, commits_after) orelse return error.NotFound).repo_commits.name; │ │101 │ │102 return .{ │ │103 .header = try Header.init(arena, repo.name, owner.name), │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │104 .repo = repo, │ │105 // the repo's event id is the on-disk repo directory name │ │106 .files = try Files.init(arena, session, &found.event_id, rf.identity, files_ref_kind, files_ref_value, files_dir),│ │101 - .commits = try Commits.init(arena, session, &found.event_id, rf.identity, commits_start, commits_after), │ │107 + .commits = commits, │ │108 .refs = try Refs.init(arena, session, &found.event_id, rf.identity, refs_kind, refs_after), │ │109 .settings = Settings.init(), │ │110 .auth = Auth.init(), │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯