╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │123 invalid.target_branch = "missing"; │ │124 try std.testing.expectError(error.InvalidTargetBranch, pch.writeBranchPatch(.local, kind, opts, io, allocator, &repo, std.fmt.bytesToHex(id, .lower), invalid, retargeted.event, author));│ │125 │ │126 + // editing metadata without changing the target must also record a patch edit. │ │127 + try evt.Patch.update(.local, kind, opts, io, allocator, &repo, &id, .{ .fields = .{ │ │128 + .title = "renamed patch", │ │129 + .tags = patch.tags, │ │130 + .description = patch.description, │ │131 + .target_branch = "other-target", │ │132 + } }, author); │ │133 + │ │134 // removing the patch leaves its branch intact │ │135 try evt.remove(.local, .repo, kind, opts, io, allocator, &repo, &id, .patch, author); │ │136 try pch.refreshBranches(.local, kind, opts, io, allocator, &repo, null, null); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │182 } │ │183 const id = [_]u8{9} ** evt.event_id_size; │ │184 const id_hex = std.fmt.bytesToHex(id, .lower); │ │185 + const before_new = try repo.core.db.rootCursor().count(); │ │186 try pch.writeBranchPatch(.server, .xit, opts, io, allocator, &repo, id_hex, .{│ │187 .title = "merge branch", │ │188 .description = "", │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │190 .source_branch = "feature", │ │191 .target_branch = "master", │ │192 }, null, author); │ │193 + try std.testing.expectEqual(before_new + 1, try repo.core.db.rootCursor().count()); │ │194 │ │195 // updating a branch and checking its mergeability counts as one patch │ │196 _ = try repo.commitAtRef(io, allocator, .{ .message = "revise feature" }, null, .{ .kind = .head, .name = "feature" });│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │200 var output = std.Io.Writer.Allocating.init(allocator); │ │201 defer output.deinit(); │ │202 var progress = push.PushProgress{ .response = &response, .writer = &output.writer, .label = "Updating patches" };│ │203 + const before_refresh = try repo.core.db.rootCursor().count(); │ │204 try pch.refreshBranches(.server, .xit, opts, io, allocator, &repo, null, &progress); │ │205 + try std.testing.expectEqual(before_refresh + 1, try repo.core.db.rootCursor().count()); │ │206 try std.testing.expect(std.mem.indexOf(u8, output.written(), "Updating patches: 100% (1/1)\n") != null); │ │207 │ │208 // closed patches skip source updates and contribute no progress │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │215 try std.testing.expectEqual(closed_progress_len, output.written().len); │ │216 │ │217 // reopening captures the latest source and checks both merge styles │ │218 + const before_reopen = try repo.core.db.rootCursor().count(); │ │219 try evt.Patch.update(.server, .xit, opts, io, allocator, &repo, &id, .{ .status = .open }, author); │ │220 + try std.testing.expectEqual(before_reopen + 1, try repo.core.db.rootCursor().count()); │ │221 var arena = std.heap.ArenaAllocator.init(allocator); │ │222 defer arena.deinit(); │ │223 const before = (try evt.readFromRepo(evt.Patch, .xit, opts, io, allocator, &arena, &repo, &id)) orelse return error.NotFound;│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │1012 // publish the metadata and revision pointer │ │1013 // │ │1014 │ │1015 + const before_publish = try target.core.db.rootCursor().count(); │ │1016 try pch.publish(repo_opts, io, allocator, &admin, &target, draft_path, .{│ │1017 .id = patch_id_hex, │ │1018 .user_id = user_id, │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │1020 .author = author, │ │1021 .timestamp = 5, │ │1022 }); │ │1023 + try std.testing.expectEqual(before_publish + 1, try target.core.db.rootCursor().count());│ │1024 try pch.publish(repo_opts, io, allocator, &admin, &target, draft_path, .{ │ │1025 .id = patch_id_hex, │ │1026 .user_id = user_id, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1225 │ │1226 // a server patch edit refreshes its mergeability │ │1227 edit.fields.title = patch.title; │ │1228 + const before_edit = try target.core.db.rootCursor().count(); │ │1229 try evt.Patch.update(.server, .xit, repo_opts, io, allocator, target, id, edit, author); │ │1230 + try std.testing.expectEqual(before_edit + 1, try target.core.db.rootCursor().count()); │ │1231 const events_before = try target.readRef(io, evt.events_ref); │ │1232 try std.testing.expectEqualDeep(pch.Mergeability{ .source = .conflict, .squash = .conflict }, try readMergeability(target, io, allocator, id, patch));│ │1233 try expectMergeabilityShortBytes(try target.core.latestMoment(), id); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯