╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────────────╮ │src/ui/Repo/Patches.zig│ ╰───────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │159 commit_count: ?u64 = null, │ │160 no_changes: bool = false, │ │161 fork_exists: bool = false, │ │162 - // the name of the user whose fork backs the patch │ │163 - forker: []const u8 = "", │ │162 + // the url identity of the fork backing the patch: its forker and the repo name it was forked under│ │163 + fork_identity: []const u8 = "", │ │164 + // whether the fork's target is gone, which leaves the fork fetchable but not pushable │ │165 + target_deleted: bool = false, │ │166 mergeability: pch.Mergeability = .{}, │ │167 }; │ │168 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │264 │ │265 pub fn listRoute(identity: []const u8, status: Status, selected: []const u8) ?ui.RoutablePage { │ │266 return ui.RoutablePage.repoPatchesRoute(identity, status, selected); │ │265 -} │ │266 - │ │267 -// a fork route's identity names the forker and the target repo │ │268 -fn forkIdentity(buffer: []u8, identity: []const u8, entry: PatchWithId) ![]const u8 { │ │269 - const repo_identity = ui.RoutablePage.RepoIdentity.parse(identity) orelse return error.RouteTooLong; │ │270 - return std.fmt.bufPrint(buffer, "{s}:{s}", .{ entry.forker, repo_identity.name }) catch error.RouteTooLong;│ │267 } │ │268 │ │269 pub fn commitsRoute(identity: []const u8, entry: PatchWithId) !?ui.RoutablePage { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │274 - var buffer: [ui.RoutablePage.repo_identity_max_len]u8 = undefined; │ │270 if (entry.fork_exists and entry.record.event.status.kind() != .merged) │ │276 - return ui.RoutablePage.forkCommitsRoute(try forkIdentity(&buffer, identity, entry), entry.id, "") orelse error.RouteTooLong;│ │271 + return ui.RoutablePage.forkCommitsRoute(entry.fork_identity, entry.id, "") orelse error.RouteTooLong; │ │272 if (entry.revision_oid.len == 0 or entry.base_oid.len == 0) return null; │ │273 return ui.RoutablePage.repoCommitsRoute(identity, .object, entry.revision_oid, entry.base_oid) orelse error.RouteTooLong; │ │274 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │279 // merged patches show what actually landed, including conflict resolutions │ │280 .merged => |merged| merged.patchrev_id, │ │281 .open, .closed => blk: { │ │287 - if (entry.fork_exists) { │ │288 - var buffer: [ui.RoutablePage.repo_identity_max_len]u8 = undefined; │ │289 - return ui.RoutablePage.forkDiffRoute(try forkIdentity(&buffer, identity, entry), entry.id, "", "", 0, "") orelse error.RouteTooLong;│ │290 - } │ │282 + if (entry.fork_exists) return ui.RoutablePage.forkDiffRoute(entry.fork_identity, entry.id, "", "", 0, "") orelse error.RouteTooLong; │ │283 if (patch.source_branch == null) return null; │ │284 break :blk (patch.revision orelse return null).id; │ │285 }, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │356 const user_id = actor.user_id orelse return error.NotFound; │ │357 const repo_id = data.repo_id orelse return error.NotFound; │ │358 const repo_user_id = actor.repo_user_id orelse return error.NotFound; │ │359 + const identity = ui.RoutablePage.RepoIdentity.parse(data.identity) orelse return error.NotFound; │ │360 if (!evt.Patch.branchValid(target_branch) or !try repo_source.hasBranch(io, allocator, target_branch)) return error.InvalidTargetBranch;│ │361 const fork_path = try fork.create(.{}, io, allocator, users_dir, .{ │ │362 .id = id, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────╮ │363 .user_id = user_id, │ │364 .repo_id = repo_id, │ │365 .repo_user_id = repo_user_id,│ │366 + .repo_name = identity.name, │ │367 .title = title, │ │368 .description = description, │ │369 .labels = labels, │ ╰──────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │761 // a fork-backed patch's fork lives in its forker's user repo │ │762 if (admin_moment) |moment| if (users_dir) |dir| if (item.record.event.source_branch == null) { │ │763 if (try fork.readForkerId(&config.sections, &id)) |forker_id| { │ │770 - if (try evt.User.readById(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, &forker_id)) |forker| item.forker = forker.event.name;│ │771 - const record = try evt.readForkById(io, arena.child_allocator, arena, dir, &forker_id, &id); │ │772 - item.fork_exists = if (record) |value| !value.removed else false; │ │764 + if (try evt.readForkById(io, arena.child_allocator, arena, dir, &forker_id, &id)) |record| if (!record.removed) { │ │765 + if (try evt.User.readById(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, &forker_id)) |forker| { │ │766 + item.fork_exists = true; │ │767 + item.fork_identity = try arena.allocator().print("{s}:{s}", .{ forker.event.name, record.event.repo_name }); │ │768 + } │ │769 + }; │ │770 } │ │771 }; │ │772 const target_branch = item.record.event.target_branch; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │866 // a fork shares its target's hash kind │ │867 var fork_repo = rp.Repo(.xit, .{ .hash = repo_opts.hash }).open(io, arena.child_allocator, .{ .path = path, .require_repo_root = true }) catch continue;│ │868 defer fork_repo.deinit(io, arena.child_allocator); │ │872 - const entry = (try loadDraftEntry(repo_kind, repo_opts, arena, io, admin_moment, &fork_repo, target_repo, id, user_name)) orelse continue; │ │869 + const record = (try evt.Fork.readById(evt.UserDB, evt.user_repo_opts.hash, user_moment, arena, &id)) orelse continue; │ │870 + const fork_identity = try aa.print("{s}:{s}", .{ user_name, record.event.repo_name }); │ │871 + const entry = (try loadDraftEntry(repo_kind, repo_opts, arena, io, admin_moment, &fork_repo, target_repo, id, fork_identity)) orelse continue; │ │872 try items.append(aa, entry); │ │873 } │ │874 return .{ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────╮ │888 fork_repo: *rp.Repo(.xit, .{ .hash = repo_opts.hash }),│ │889 target_repo: *rp.Repo(repo_kind, repo_opts), │ │890 id: [evt.event_id_size]u8, │ │892 - forker: []const u8, │ │891 + fork_identity: []const u8, │ │892 ) !?PatchWithId { │ │893 const aa = arena.allocator(); │ │894 const id_hex = std.fmt.bytesToHex(id, .lower); │ ╰────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────╮ │910 .commit_count = commit_count, │ │911 .no_changes = if (target_oid) |oid| std.mem.eql(u8, &oid, &fork_oid) else false,│ │912 .fork_exists = true, │ │914 - .forker = try aa.dupe(u8, forker), │ │913 + .fork_identity = try aa.dupe(u8, fork_identity), │ │914 }; │ │915 } │ │916 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯