╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
821 // `data.handle.location`. 822 fn commitsLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 823 const route = data.handle.location.commitsRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 824 const url = try route.toUrl(page_arena); 825 return page_arena.allocator().print("a:{s}", .{url}); 826 } 827 828 // this list's page starting at `oid`: a repo's branch or tag keeps its ref (and 829 // its query) and moves `from` along, so the search box survives paging. a fork 830 // or an object view roots the page at the commit itself. 831 fn pageRoute(data: *const Self, oid: []const u8) ?ui.RoutablePage { 832 if (data.handle.location != .repo or data.ref_or_oid == .object) { 833 return data.handle.location.commitsRoute(.object, oid, data.base_oid); 834 } 835 const route = data.handle.location.commitsRoute(data.ref_or_oid, data.ref_or_oid_value, data.base_oid) orelse return null; 836 const paged = route.withFrom(oid) orelse return null; 837 return paged.withSearch(data.search orelse return paged); 838 } 839 840 fn nextPageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 841 const route = pageRoute(data, oid) orelse return error.RouteTooLong; 842 const url = try route.toUrl(page_arena); 843 return page_arena.allocator().print("a:{s}", .{url}); 844 } 845 846 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 847 // directory, within `location`. 848 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, location: ui.RoutablePage.RepoLocation, oid: []const u8) ![]const u8 { 849 const route = location.filesRoute(.object, oid, "", 0) orelse return error.RouteTooLong; 850 const url = try route.toUrl(page_arena); 851 return page_arena.allocator().print("a:{s}", .{url}); 852 } 853 854 // the in-page "ai:" anchor for selecting a commit, showing its whole message 855 // when `message` is set. the href is only followed with js off. 856 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, commit: Commit, message: bool) ![]const u8 { 857 // a result roots the same results page at its commit, so the query 858 // survives following the row 859 if (data.search != null) { 860 const route = pageRoute(data, commit.oid) orelse return error.RouteTooLong; 861 return page_arena.allocator().print("ai:{s}", .{try route.toUrl(page_arena)}); 862 } 863 const route = (if (message) 864 data.handle.location.commitMessageRoute(.object, commit.oid, data.base_oid) 865 else 866 data.handle.location.commitsRoute(.object, commit.oid, data.base_oid)) orelse return error.RouteTooLong; 867 const url = try route.toUrl(page_arena); 868 return page_arena.allocator().print("ai:{s}", .{url}); 869 } 870 871 // the "a:" link to the page showing `oid`'s message on its own. 872 fn messageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 873 const route = data.handle.location.commitMessageRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 874 const url = try route.toUrl(page_arena); 875 return page_arena.allocator().print("a:{s}", .{url}); 876 } 877