╭ changed ───────╮ │src/test/net.zig│ ╰────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────╮ │ 4 const xit = hx.xit; │ │ 5 const evt = hx.event; │ │ 6 const fork = hx.fork; │ │ 7 +const pch = hx.pch; │ │ 8 const rp = xit.repo; │ │ 9 const rf = xit.ref; │ │10 const work = xit.workdir;│ ╰─────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │551 try file.writeStreamingAll(io, "base contents\n"); │ │552 try target_repo.add(io, allocator, &.{"main.txt"}); │ │553 _ = try target_repo.commit(io, allocator, .{ .author = "admin <admin@example.test>", .message = "initial code" });│ │554 + try target_repo.addConfig(io, allocator, .{ .name = "receive.denycurrentbranch", .value = "updateinstead" }); │ │555 } │ │556 │ │557 const other_path = (try repoOnDiskPath(io, allocator, temp_dir_name, "other", true)).?; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │628 const moment = try evt.currentMoment(.{}, &draft); │ │629 const patch = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &fork_id)) orelse return error.NotFound; │ │630 try std.testing.expect(!patch.removed); │ │629 - first_revision_id = try evt.parseEventId(&(patch.event.patchrev_id orelse return error.NotFound)); │ │631 + first_revision_id = try evt.parseEventId(&(patch.event.revision orelse return error.NotFound).id); │ │632 const revision = (try evt.PatchRev.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &first_revision_id)) orelse return error.NotFound;│ │633 try std.testing.expectEqualStrings("refs/heads/master", revision.event.target_ref); │ │634 try std.testing.expectEqualStrings(&source_oid, revision.event.source_oid); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────╮ │635 } │ │636 │ │637 // │ │636 - // publish, then push another revision│ │638 + // post, then push another revision │ │639 // │ │640 │ │641 { │ ╰───────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │643 defer admin.deinit(io, allocator); │ │644 var target = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = target_path });│ │645 defer target.deinit(io, allocator); │ │644 - try fork.publish(.{}, io, allocator, &admin, &target, draft_path, .{ │ │646 + try pch.post(.{}, io, allocator, &admin, &target, draft_path, .{ │ │647 .id = fork_id_hex, │ │648 .user_id = user_id, │ │649 .repo_id = repo_id, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────╮ │663 .description = patch.event.description, │ │664 .tags = patch.event.tags, │ │665 .target_patch_id = patch.event.target_patch_id,│ │664 - .patchrev_id = patch.event.patchrev_id, │ │666 + .revision = patch.event.revision, │ │667 } }, │ │668 }}); │ │669 } │ ╰────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │678 try client.push(io, allocator, "patch", "master:patch", false, .{ .wire = .{ .ssh = .{ .command = ssh_cmd } } });│ │679 │ │680 var second_revision_id: [evt.event_id_size]u8 = undefined; │ │681 + var second_patch_oid: [hash.hexLen(.sha1)]u8 = undefined; │ │682 { │ │683 var draft = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = draft_path }); │ │684 defer draft.deinit(io, allocator); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │689 try std.testing.expect(patch.removed); │ │690 const newest = (try evt.PatchRev.readNewest(evt.EventDB(.sha1), .sha1, moment, &arena)) orelse return error.NotFound;│ │691 second_revision_id = newest.id; │ │692 + @memcpy(&second_patch_oid, newest.record.patch_oid); │ │693 try std.testing.expect(!std.mem.eql(u8, &first_revision_id, &second_revision_id)); │ │694 try std.testing.expectEqualStrings(&second_source_oid, newest.record.event.source_oid); │ │695 try std.testing.expectEqualStrings("edited feature", newest.record.event.message); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │702 const moment = try evt.currentMoment(.{}, &target); │ │703 const patch = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &fork_id)) orelse return error.NotFound; │ │704 try std.testing.expectEqualStrings("edited feature", patch.event.title); │ │701 - try std.testing.expectEqualStrings(&std.fmt.bytesToHex(second_revision_id, .lower), &(patch.event.patchrev_id orelse return error.NotFound));│ │705 + try std.testing.expectEqualStrings(&std.fmt.bytesToHex(second_revision_id, .lower), &(patch.event.revision orelse return error.NotFound).id);│ │706 } │ │707 │ │708 // │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │751 const moment = try evt.currentMoment(.{}, &target); │ │752 const patch = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &fork_id)) orelse return error.NotFound; │ │753 try std.testing.expect(patch.removed); │ │754 + } │ │755 + │ │756 + // │ │757 + // restore the patch, merge its source oid, and push the merge │ │758 + // │ │759 + │ │760 + { │ │761 + var target = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = target_path }); │ │762 + defer target.deinit(io, allocator); │ │763 + var arena = std.heap.ArenaAllocator.init(allocator); │ │764 + defer arena.deinit(); │ │765 + const moment = try evt.currentMoment(.{}, &target); │ │766 + const removed = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &fork_id)) orelse return error.NotFound; │ │767 + try evt.consume(.repo, .xit, .{}, io, allocator, &target, evt.events_ref, &.{.{ │ │768 + .id = fork_id_hex, │ │769 + .timestamp = 4, │ │770 + .author = .{ .name = "admin", .email = "admin@example.test" }, │ │771 + .event = .{ .patch = removed.event }, │ │772 + }}); │ │773 + } │ │774 + const merge_parents = [_][hash.hexLen(.sha1)]u8{ third_source_oid, second_source_oid }; │ │775 + _ = try client.commit(io, allocator, .{ .message = "merge patch", .parent_oids = &merge_parents }); │ │776 + try client.push(io, allocator, "origin", "master:master", false, .{ .wire = .{ .ssh = .{ .command = ssh_cmd } } }); │ │777 + { │ │778 + var target = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = target_path }); │ │779 + defer target.deinit(io, allocator); │ │780 + var arena = std.heap.ArenaAllocator.init(allocator); │ │781 + defer arena.deinit(); │ │782 + const moment = try evt.currentMoment(.{}, &target); │ │783 + const patch = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &fork_id)) orelse return error.NotFound; │ │784 + try std.testing.expectEqual(.merged, patch.event.status); │ │785 + const imported = (try evt.PatchRev.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &second_revision_id)) orelse return error.NotFound;│ │786 + try std.testing.expectEqualStrings(&second_patch_oid, imported.patch_oid); │ │787 } │ │788 │ │789 const other_url = try std.fmt.allocPrint(allocator, "git@localhost:admin/other/patch:{s}/branch:other", .{&fork_id_hex}); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯