╭ changed ──────────────╮ │src/ui/Repo/Patches.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────╮ │ 5 const xit = @import("xit"); │ │ 6 const rp = xit.repo; │ │ 7 const hash = xit.hash; │ │ 8 +const rf = xit.ref; │ │ 9 const diff3 = @import("../../diff3.zig"); │ │10 const Comment = @import("Comment.zig"); │ │11 const Attachment = @import("Attachment.zig");│ ╰─────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │38 attachments: []const Attachment.WithId = &.{},│ │39 draft: bool = false, │ │40 revision_ready: bool = false, │ │41 + fork_oid: []const u8 = "", │ │42 + target_branch: []const u8 = "", │ │43 + no_changes: bool = false, │ │44 }; │ │45 │ │46 pub const Entry = PatchWithId; │ ╰──────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────╮ │120 // (the web posts the new-patch form to the patch route instead).│ │121 repo_source: ?ui.RepoSource = null, │ │122 repo_id: ?[evt.event_id_size]u8 = null, │ │119 -target_branch: []const u8 = "", │ │123 │ │124 const Self = @This(); │ │125 │ ╰──────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────╮ │263 session: *ui.Session, │ │264 repo_id_maybe: ?[evt.event_id_size]u8,│ │265 identity: []const u8, │ │266 + target_branch: []const u8, │ │267 tag: []const u8, │ │268 selected_id: []const u8, │ │269 comment_id: []const u8, │ ╰───────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │281 const drafts_window = if (admin_moment) |admin| │ │282 if (repo_id_maybe) |repo_id| │ │283 if (session.data.user_id != null and session.repos_dir != null) │ │280 - try loadDraftWindow(arena, session, admin, &repo_id, empty.selected_id) │ │284 + try loadDraftWindow(repo_kind, repo_opts, arena, session, admin, &repo_id, empty.selected_id, repo, target_branch)│ │285 else │ │286 Window.empty │ │287 else │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────╮ │446 } │ │447 │ │448 fn loadDraftWindow( │ │449 + comptime repo_kind: rp.RepoKind, │ │450 + comptime repo_opts: rp.RepoOpts(repo_kind), │ │451 arena: *std.heap.ArenaAllocator, │ │452 session: *ui.Session, │ │453 admin_moment: evt.AdminDB.HashMap(.read_only),│ ╰───────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────╮ │454 repo_id: *const [evt.event_id_size]u8, │ │455 selected_id: []const u8, │ │456 + target_repo: *rp.Repo(repo_kind, repo_opts), │ │457 + default_target_branch: []const u8, │ │458 ) !Window { │ │459 const user_id = session.data.user_id orelse return .empty;│ │460 if (user_id.len != evt.event_id_size) return .empty; │ ╰───────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │506 const path = try fork.forkPath(aa, repos_dir, &id_hex); │ │507 var fork_repo = rp.Repo(.xit, .{}).open(io, arena.child_allocator, .{ .path = path, .require_repo_root = true }) catch continue;│ │508 defer fork_repo.deinit(io, arena.child_allocator); │ │509 + const fork_oid = (try fork_repo.readRef(io, fork.ref)) orelse continue; │ │510 const moment = evt.currentMoment(.{}, &fork_repo) catch continue; │ │511 const patch = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, arena, &id)) orelse continue; │ │512 var revision_ready = false; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │513 + var target_branch = default_target_branch; │ │514 if (patch.event.revision) |revision| { │ │515 + const target_ref = rf.Ref.initFromPath(revision.target_ref, null) orelse continue; │ │516 + target_branch = switch (target_ref.kind) { │ │517 + .head => target_ref.name, │ │518 + else => continue, │ │519 + }; │ │520 const revision_id = evt.parseEventId(&revision.id) catch continue; │ │521 if (try evt.PatchRev.readById(evt.EventDB(.sha1), .sha1, moment, arena, &revision_id)) |record|│ │522 revision_ready = revision.matches(record); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │523 } │ │524 + const target_oid = if (target_branch.len != 0) │ │525 + try target_repo.readRef(io, .{ .kind = .head, .name = target_branch })│ │526 + else │ │527 + null; │ │528 try items.append(aa, .{ │ │529 .id = try aa.dupe(u8, &id_hex), │ │530 .record = patch, │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯