╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
878 } 879 880 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 881 const header_view = self.header() orelse return false; 882 return header_view.focusHeader(root_focus); 883 } 884 }; 885 886 // the "a:" navigation link for the commits page walking from commit `oid` within 887 // `data.location`, windowing the selected commit's diff from hunk `start`, filtered 888 // to `path` ("" = every file). 889 fn commitsLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8, start: usize, path: []const u8) ![]const u8 { 890 const route = data.location.commitsRoute(.object, oid, start, path, data.base_oid) orelse return error.RouteTooLong; 891 const url = try route.toUrl(page_arena); 892 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 893 } 894 895 // this list's page starting at `oid`: a repo's branch or tag keeps its ref (and 896 // its query) and moves `from` along, so the search box survives paging. a fork 897 // or an object view roots the page at the commit itself. 898 fn pageRoute(data: *const Self, oid: []const u8) ?ui.RoutablePage { 899 if (data.location != .repo or data.ref_or_oid == .object) { 900 return data.location.commitsRoute(.object, oid, 0, "", data.base_oid); 901 } 902 const route = data.location.commitsRoute(data.ref_or_oid, data.ref_or_oid_value, 0, "", data.base_oid) orelse return null; 903 const paged = route.withFrom(oid) orelse return null; 904 return paged.withSearch(data.search orelse return paged); 905 } 906 907 fn nextPageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 908 const route = pageRoute(data, oid) orelse return error.RouteTooLong; 909 const url = try route.toUrl(page_arena); 910 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 911 } 912 913 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 914 // directory, within `location`. 915 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, location: ui.RoutablePage.RepoLocation, oid: []const u8) ![]const u8 { 916 const route = location.filesRoute(.object, oid, "", 0) orelse return error.RouteTooLong; 917 const url = try route.toUrl(page_arena); 918 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 919 } 920 921 // the in-page "ai:" anchor for selecting a commit with its current pane content 922 // and window. the href is only followed with js off. 923 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, commit: Commit, content: Content) ![]const u8 { 924 // a result roots the same results page at its commit, so the query 925 // survives following the row 926 if (data.search != null) { 927 const route = pageRoute(data, commit.oid) orelse return error.RouteTooLong; 928 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{try route.toUrl(page_arena)}); 929 } 930 const route = (switch (content) { 931 .message => data.location.commitMessageRoute(.object, commit.oid, data.base_oid), 932 .diff => |diff| data.location.commitsRoute(.object, commit.oid, commit.window.start, diff.path, data.base_oid), 933 }) orelse return error.RouteTooLong; 934 const url = try route.toUrl(page_arena); 935 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 936 } 937 938 // the "a:" link to the page showing `oid`'s message on its own. 939 fn messageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 940 const route = data.location.commitMessageRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 941 const url = try route.toUrl(page_arena); 942 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 943 } 944