╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │363 .{ .tree = .{ .name = "head", .oid = &source_b_tree } }, │ │364 }; │ │365 { │ │335 - try evt.consume(.repo, .xit, repo_opts, io, allocator, &target, evt.events_ref, &.{ │ │336 - .{ │ │337 - .id = std.fmt.bytesToHex(child_patchrev_id, .lower), │ │338 - .timestamp = 12, │ │339 - .author = author, │ │340 - .tree_entries = &child_entries, │ │341 - .event = .{ .patchrev = .{ .base_oid = merged_patchrev.patch_oid, .source_oid = &source_b_oid, .target_ref = "refs/heads/master", .message = "stack another answer change" } },│ │342 - }, │ │343 - .{ │ │344 - .id = std.fmt.bytesToHex(child_id, .lower), │ │345 - .timestamp = 13, │ │346 - .author = author, │ │347 - .event = .{ .patch = .{ │ │348 - .title = "stack another answer change", │ │349 - .description = "depends on the first patch", │ │350 - .tags = "enhancement", │ │351 - .target_patch_id = std.fmt.bytesToHex(patch_id, .lower), │ │352 - .patchrev_id = std.fmt.bytesToHex(child_patchrev_id, .lower), │ │353 - } }, │ │354 - }, │ │355 - }); │ │366 + try consumePatchWithRevision(.repo, io, allocator, &target, evt.events_ref, child_patchrev_id, .{ │ │367 + .base_oid = merged_patchrev.patch_oid, │ │368 + .source_oid = &source_b_oid, │ │369 + .target_ref = "refs/heads/master", │ │370 + .message = "stack another answer change", │ │371 + }, &child_entries, 12, child_id, .{ │ │372 + .title = "stack another answer change", │ │373 + .description = "depends on the first patch", │ │374 + .tags = "enhancement", │ │375 + .target_patch_id = std.fmt.bytesToHex(patch_id, .lower), │ │376 + }, 13); │ │377 } │ │378 │ │379 // │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │359 - // check the derived commit and reverse index│ │380 + // check the squash commit and reverse index │ │381 // │ │382 │ │383 _ = arena.reset(.retain_capacity); │ ╰──────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │384 const stacked_moment = try evt.currentMoment(repo_opts, &target); │ │385 const child = (try evt.Patch.readById(Repo.DB, repo_opts.hash, stacked_moment, &arena, &child_id)) orelse return error.NotFound; │ │386 var selected_patchrev_id: [evt.event_id_size]u8 = undefined; │ │366 - _ = try std.fmt.hexToBytes(&selected_patchrev_id, &(child.event.patchrev_id orelse return error.NotFound)); │ │387 + _ = try std.fmt.hexToBytes(&selected_patchrev_id, &(child.event.revision orelse return error.NotFound).id); │ │388 const child_patchrev = (try evt.PatchRev.readById(Repo.DB, repo_opts.hash, stacked_moment, &arena, &selected_patchrev_id)) orelse return error.NotFound;│ │389 var child_oid: [hash.hexLen(repo_opts.hash)]u8 = undefined; │ │390 @memcpy(&child_oid, child_patchrev.patch_oid); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │614 const initial_patch = (try evt.Patch.readById(Repo.DB, repo_opts.hash, initial_moment, &arena, &patch_id)) orelse return error.NotFound;│ │615 try std.testing.expect(!initial_patch.removed); │ │616 try std.testing.expectEqualStrings("add the answer", initial_patch.event.title); │ │596 - try std.testing.expectEqual(null, initial_patch.event.patchrev_id); │ │617 + try std.testing.expectEqual(null, initial_patch.event.revision); │ │618 try std.testing.expectEqual(null, try evt.PatchRev.readNewest(Repo.DB, repo_opts.hash, initial_moment, &arena)); │ │619 │ │620 var source_moment = try source.core.latestMoment(); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │623 defer objects.deinit(); │ │624 try objects.include(&source_oid); │ │625 try draft.copyObjects(.xit, repo_opts, &objects, io, null); │ │605 - try evt.consume(.fork, .xit, repo_opts, io, allocator, &draft, evt.events_ref, &.{ │ │606 - .{ │ │607 - .id = first_patchrev_hex, │ │608 - .timestamp = 3, │ │609 - .author = author, │ │610 - .tree_entries = &first_entries, │ │611 - .event = .{ .patchrev = .{ │ │612 - .base_oid = &base_oid, │ │613 - .source_oid = &source_oid, │ │614 - .target_ref = "refs/heads/master", │ │615 - .message = "add the answer", │ │616 - } }, │ │617 - }, │ │618 - .{ │ │619 - .id = patch_id_hex, │ │620 - .timestamp = 3, │ │621 - .author = author, │ │622 - .event = .{ .patch = .{ │ │623 - .title = "add the answer", │ │624 - .tags = "enhancement", │ │625 - .description = "adds a reusable answer constant", │ │626 - .patchrev_id = first_patchrev_hex, │ │627 - } }, │ │628 - }, │ │629 - }); │ │626 + try consumePatchWithRevision(.fork, io, allocator, &draft, evt.events_ref, first_patchrev_id, .{│ │627 + .base_oid = &base_oid, │ │628 + .source_oid = &source_oid, │ │629 + .target_ref = "refs/heads/master", │ │630 + .message = "add the answer", │ │631 + }, &first_entries, 3, patch_id, .{ │ │632 + .title = "add the answer", │ │633 + .tags = "enhancement", │ │634 + .description = "adds a reusable answer constant", │ │635 + }, 3); │ │636 │ │637 _ = arena.reset(.retain_capacity); │ │638 const moment = try evt.currentMoment(repo_opts, &draft); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │639 const patch = (try evt.Patch.readById(Repo.DB, repo_opts.hash, moment, &arena, &patch_id)) orelse return error.NotFound;│ │640 try std.testing.expect(!patch.removed); │ │635 - try std.testing.expectEqualStrings(&first_patchrev_hex, &(patch.event.patchrev_id orelse return error.NotFound)); │ │641 + try std.testing.expectEqualStrings(&first_patchrev_hex, &(patch.event.revision orelse return error.NotFound).id); │ │642 try std.testing.expect(null != try evt.PatchRev.readById(Repo.DB, repo_opts.hash, moment, &arena, &first_patchrev_id)); │ │643 } │ │644 try std.testing.expectError(error.NotFound, evt.currentMoment(repo_opts, &target)); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │645 │ │646 // │ │641 - // publish the metadata and revision pointer │ │647 + // post the metadata and revision pointer │ │648 // │ │649 │ │644 - try fork.publish(repo_opts, io, allocator, &admin, &target, draft_path, .{│ │650 + try pch.post(repo_opts, io, allocator, &admin, &target, draft_path, .{ │ │651 .id = patch_id_hex, │ │652 .user_id = user_id, │ │653 .repo_id = repo_id, │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │654 .author = author, │ │655 .timestamp = 3, │ │656 }); │ │651 - try fork.publish(repo_opts, io, allocator, &admin, &target, draft_path, .{│ │657 + try pch.post(repo_opts, io, allocator, &admin, &target, draft_path, .{ │ │658 .id = patch_id_hex, │ │659 .user_id = user_id, │ │660 .repo_id = repo_id, │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │666 defer arena.deinit(); │ │667 const moment = try evt.currentMoment(repo_opts, &target); │ │668 const patch = (try evt.Patch.readById(Repo.DB, repo_opts.hash, moment, &arena, &patch_id)) orelse return error.NotFound; │ │663 - try std.testing.expectEqualStrings(&first_patchrev_hex, &(patch.event.patchrev_id orelse return error.NotFound)); │ │669 + try std.testing.expectEqualStrings(&first_patchrev_hex, &(patch.event.revision orelse return error.NotFound).id); │ │670 try std.testing.expectEqual(.open, patch.event.status); │ │671 try std.testing.expectEqual(null, try evt.PatchRev.readById(Repo.DB, repo_opts.hash, moment, &arena, &first_patchrev_id));│ │672 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │673 _ = arena.reset(.retain_capacity); │ │674 const admin_moment = try evt.currentMoment(evt.admin_repo_opts, &admin); │ │669 - const published_fork = (try evt.Fork.readById(evt.AdminDB, evt.admin_repo_opts.hash, admin_moment, &arena, &patch_id)) orelse return error.NotFound;│ │670 - try std.testing.expect(!published_fork.removed); │ │671 - try std.testing.expectEqual(.posted, published_fork.event.stage); │ │675 + const posted_fork = (try evt.Fork.readById(evt.AdminDB, evt.admin_repo_opts.hash, admin_moment, &arena, &patch_id)) orelse return error.NotFound; │ │676 + try std.testing.expect(!posted_fork.removed); │ │677 + try std.testing.expectEqual(.posted, posted_fork.event.stage); │ │678 const draft_key = evt.Fork.draftKey(&repo_id, &user_id); │ │679 try std.testing.expectEqual(0, try indexedForkCount(admin_moment, evt.Fork.repo_user_to_draft_id_set_key, &draft_key)); │ │680 try std.testing.expectEqual(1, try indexedForkCount(admin_moment, evt.Fork.user_id_to_fork_id_set_key, &user_id)); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯