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