╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────╮ │27 }; │ │28 } │ │29 │ │30 -test "patch lifecycle" { │ │30 +test "patch event conflicts, stacking, and gc" {│ │31 const io = std.testing.io; │ │32 const allocator = std.testing.allocator; │ │33 const temp_dir_name = "temp-event-patch"; │ ╰────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────╮ │110 .title = "add the answer", │ │111 .description = "adds a reusable answer constant", │ │112 .tags = "enhancement", │ │113 - .target_ref = "refs/heads/master", │ │113 .patchrev_id = std.fmt.bytesToHex(patchrev_id, .lower),│ │114 }; │ │115 const tree_entries = [_]evt.EventTreeEntry{ │ ╰────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │128 .timestamp = 3, │ │129 .author = author, │ │130 .tree_entries = &tree_entries, │ │132 - .event = .{ .patchrev = .{ .base_oid = &base_oid, .source_oid = &source_oid, .message = patch.title } }, │ │131 + .event = .{ .patchrev = .{ .base_oid = &base_oid, .source_oid = &source_oid, .target_ref = "refs/heads/master", .message = patch.title } },│ │132 }, │ │133 .{ │ │134 .id = std.fmt.bytesToHex(patch_id, .lower), │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │150 const patchrev_record = (try evt.PatchRev.readById(Repo.DB, repo_opts.hash, moment, &arena, &patchrev_id)) orelse return error.NotFound; │ │151 try std.testing.expectEqualStrings(&base_tree_oid, patchrev_record.base_tree_oid); │ │152 try std.testing.expectEqualStrings(&head_tree_oid, patchrev_record.head_tree_oid); │ │154 - try std.testing.expectEqualStrings(&std.fmt.bytesToHex(patchrev_id, .lower), &patch_record.event.patchrev_id); │ │153 + try std.testing.expectEqualStrings(&std.fmt.bytesToHex(patchrev_id, .lower), &(patch_record.event.patchrev_id orelse return error.NotFound));│ │154 │ │155 var initial_patch_oid: [hash.hexLen(repo_opts.hash)]u8 = undefined; │ │156 @memcpy(&initial_patch_oid, patchrev_record.patch_oid); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │248 .timestamp = 8, │ │249 .author = author, │ │250 .tree_entries = &target_entries, │ │252 - .event = .{ .patchrev = .{ .base_oid = &base_oid, .source_oid = &source_a_oid, .message = updated_patch.title } }, │ │251 + .event = .{ .patchrev = .{ .base_oid = &base_oid, .source_oid = &source_a_oid, .target_ref = "refs/heads/master", .message = updated_patch.title } },│ │252 }, │ │253 .{ │ │254 .id = std.fmt.bytesToHex(patch_id, .lower), │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │277 .timestamp = 10, │ │278 .author = author, │ │279 .tree_entries = &parent_entries, │ │281 - .event = .{ .patchrev = .{ .base_oid = &base_oid, .source_oid = &source_b_oid, .message = updated_patch.title } }, │ │280 + .event = .{ .patchrev = .{ .base_oid = &base_oid, .source_oid = &source_b_oid, .target_ref = "refs/heads/master", .message = updated_patch.title } },│ │281 }, │ │282 .{ │ │283 .id = std.fmt.bytesToHex(patch_id, .lower), │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │304 _ = arena.reset(.retain_capacity); │ │305 const merged_moment = try evt.currentMoment(repo_opts, &target); │ │306 const merged = (try evt.Patch.readById(Repo.DB, repo_opts.hash, merged_moment, &arena, &patch_id)) orelse return error.NotFound; │ │308 - try std.testing.expectEqualStrings(&std.fmt.bytesToHex(patchrev_a_id, .lower), &merged.event.patchrev_id); │ │307 + try std.testing.expectEqualStrings(&std.fmt.bytesToHex(patchrev_a_id, .lower), &(merged.event.patchrev_id orelse return error.NotFound)); │ │308 const merged_patchrev = (try evt.PatchRev.readById(Repo.DB, repo_opts.hash, merged_moment, &arena, &patchrev_a_id)) orelse return error.NotFound;│ │309 try std.testing.expectEqualStrings(&source_a_oid, merged_patchrev.event.source_oid); │ │310 try std.testing.expectEqualStrings(&source_a_tree, merged_patchrev.head_tree_oid); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │317 try std.testing.expectEqualStrings("patchrev_id", try fields_cursor.readBytesAlloc(arena.allocator(), null)); │ │318 const their_cursor = try conflict.getCursor(hash.hashInt(repo_opts.hash, evt.their_record_key)) orelse return error.NotFound; │ │319 const theirs = try evt.read(evt.Patch.Record, Repo.DB, repo_opts.hash, &arena, try Repo.DB.HashMap(.read_only).init(their_cursor)); │ │321 - try std.testing.expectEqualStrings(&std.fmt.bytesToHex(patchrev_b_id, .lower), &theirs.event.patchrev_id); │ │320 + try std.testing.expectEqualStrings(&std.fmt.bytesToHex(patchrev_b_id, .lower), &(theirs.event.patchrev_id orelse return error.NotFound));│ │321 │ │322 // │ │323 // create a patch stacked on the selected revision │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │336 .timestamp = 12, │ │337 .author = author, │ │338 .tree_entries = &child_entries, │ │340 - .event = .{ .patchrev = .{ .base_oid = merged_patchrev.patch_oid, .source_oid = &source_b_oid, .message = "stack another answer change" } }, │ │339 + .event = .{ .patchrev = .{ .base_oid = merged_patchrev.patch_oid, .source_oid = &source_b_oid, .target_ref = "refs/heads/master", .message = "stack another answer change" } },│ │340 }, │ │341 .{ │ │342 .id = std.fmt.bytesToHex(child_id, .lower), │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │346 .title = "stack another answer change", │ │347 .description = "depends on the first patch", │ │348 .tags = "enhancement", │ │350 - .target_ref = patch.target_ref, │ │349 .target_patch_id = std.fmt.bytesToHex(patch_id, .lower), │ │350 .patchrev_id = std.fmt.bytesToHex(child_patchrev_id, .lower),│ │351 } }, │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯