╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────╮ │src/ui/Fork.zig│ ╰───────────────╯ ╭──────────────────────────────────────────────────────╮ │15 pub const Header = @import("./Fork/Header.zig"); │ │16 pub const Files = @import("./Repo/Files.zig"); │ │17 pub const Commits = @import("./Repo/Commits.zig");│ │18 +pub const Diff = @import("./Repo/Diff.zig"); │ │19 pub const Patches = @import("./Repo/Patches.zig");│ │20 pub const Settings = @import("./Settings.zig"); │ │21 pub const Auth = @import("./Auth.zig"); │ ╰──────────────────────────────────────────────────────╯ ╭───────────────────────╮ │25 files: Files, │ │26 commits: Commits, │ │27 patch: Patches, │ │28 +diff: Diff, │ │29 settings: Settings,│ │30 auth: Auth, │ │31 quit: Quit, │ ╰───────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │127 } }; │ │128 const files = try Files.init(.xit, .{}, arena, &fork_repo, io, arena.child_allocator, location, requested_ref, requested_value, files_path, files_line); │ │129 const commits = try Commits.init(.xit, .{}, arena, &fork_repo, io, arena.child_allocator, haxy_moment, location, requested_ref, requested_value, commits_content, commits_base_oid);│ │130 + const diff_start: usize = switch (route) { │ │131 + .fork_diff => |d| d.start, │ │132 + else => 0, │ │133 + }; │ │134 + const diff_path = switch (route) { │ │135 + .fork_diff => |*d| try aa.dupe(u8, d.path.slice()), │ │136 + else => "", │ │137 + }; │ │138 │ │139 return .{ │ │140 .header = try Header.init(arena, target_record.event.name, owner.event.name, &id_hex, requested_value), │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │141 .files = files, │ │142 .commits = commits, │ │143 .patch = patch_data, │ │144 + .diff = .{ │ │145 + .route = .{ .fork = .{ .identity = try aa.dupe(u8, identity.identity), .id = try aa.dupe(u8, &id_hex) } }, │ │146 + .path = diff_path, │ │147 + .window = try Diff.render(.xit, .{}, io, arena.child_allocator, aa, &fork_repo, &commits_base_oid, fork_oid, diff_start, diff_path),│ │148 + }, │ │149 .settings = Settings.init(), │ │150 .auth = Auth.init(), │ │151 .quit = Quit.init(), │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │174 errdefer patch_detail.deinit(allocator); │ │175 try stack.children.put(allocator, patch_detail.getFocus().id, .{ .repo_patch_detail = patch_detail });│ │176 { │ │177 + var diff = try Diff.View.init(allocator, &data.diff, session); │ │178 + errdefer diff.deinit(allocator); │ │179 + try stack.children.put(allocator, diff.getFocus().id, .{ .diff_view = diff }); │ │180 + } │ │181 + { │ │182 var files = try Files.View.init(allocator, &data.files, session); │ │183 errdefer files.deinit(allocator); │ │184 try stack.children.put(allocator, files.getFocus().id, .{ .repo_files = files }); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─────────────╮ │src/ui/Fork/Header.zig│ ╰──────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │91 const current_tag = std.meta.activeTag(session.data.current_page); │ │92 const routes = [_]ui.RoutablePage{ │ │93 ui.RoutablePage.forkPatchRoute(identity, data.id) orelse return error.RouteTooLong, │ │94 + ui.RoutablePage.forkDiffRoute(identity, data.id, 0, "") orelse return error.RouteTooLong, │ │95 ui.RoutablePage.forkFilesRoute(identity, data.id, data.oid, "", 0) orelse return error.RouteTooLong, │ │96 ui.RoutablePage.forkCommitsRoute(identity, data.id, data.oid, 0, "") orelse return error.RouteTooLong,│ │97 }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 97 - const tags = [_]std.meta.Tag(ui.RoutablePage){ .fork_patch, .fork_files, .fork_commits }; │ │ 98 - const labels = [_][]const u8{ "patch", "files", commits_label }; │ │ 98 + const tags = [_]std.meta.Tag(ui.RoutablePage){ .fork_patch, .fork_diff, .fork_files, .fork_commits };│ │ 99 + const labels = [_][]const u8{ "patch", "diff", "files", commits_label }; │ │100 var selected_tab: ?usize = null; │ │101 │ │102 for (routes, tags, labels) |route, tag, label| { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──────────────╮ │src/ui/Repo/Commits.zig│ ╰───────────────────────╯ ╭─────────────────────────────────────────╮ │ 4 const ui = @import("../../ui.zig"); │ │ 5 const xit = @import("xit"); │ │ 6 const rp = xit.repo; │ │ 7 -const df = xit.diff; │ │ 7 +pub const Diff = @import("Diff.zig");│ │ 8 const xitui = xit.xitui; │ │ 9 const wgt = xitui.widget; │ │10 const layout = xitui.layout; │ ╰─────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │17 const page_size = 20; │ │18 // how many diff hunks one window of a commit's diff shows; "next"/"previous"│ │19 // move to the adjacent window. │ │20 -const diff_page = 10; │ │20 // the largest message read even when it has fewer than the preview's line │ │21 // limit. │ │22 const max_message_size = 100 * 1024; │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │23 │ │25 -pub const Hunk = struct { │ │26 - path: ?[]const u8 = null, // the file this hunk belongs to │ │27 - lines: []const []const u8, │ │28 -}; │ │29 - │ │24 // one commit on the current page, with its diff against its first parent │ │25 // pre-rendered up to the budget so the web client can show it without a repo.│ │26 pub const Commit = struct { │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯