╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭────────────────────────────────────────────────────────────────────────╮ │385 defer json.deinit(); │ │386 │ │400 - for (events_to_consume) |event| { │ │387 + for (events_to_consume, 0..) |event, i| { │ │388 json.clearRetainingCapacity(); │ │389 │ │390 try std.json.Stringify.value(event, .{}, &json.writer);│ ╰────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │391 │ │392 // commit the event into a special branch │ │406 - _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" }); │ │393 + const oid = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" });│ │394 + if (i == 0) { │ │395 + _ = try std.fmt.hexToBytes(&first_oid, &oid); │ │396 + } │ │397 } │ │398 } │ │399 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │400 // │ │411 - // read and parse all of the events from the repo │ │412 - // │ │413 - │ │414 - const events = try readEventsFromRepo(Repo, repo_opts.hash, io, &arena, &repo, "haxy/meta");│ │415 - │ │416 - // │ │401 // consume events into the database │ │402 // │ │403 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │404 { │ │421 - try evt.consume(repo_opts, io, allocator, &repo, events); │ │405 + try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │406 │ │407 const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly());│ │408 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │496 io, │ │497 allocator, │ │498 // make the first commit a child of the first commit on the haxy/meta branch │ │515 - .{ .parent_oids = if (i == 0) &.{std.fmt.bytesToHex(events[events.len - 1].oid, .lower)} else null, .message = json.written() },│ │499 + .{ .parent_oids = if (i == 0) &.{std.fmt.bytesToHex(first_oid, .lower)} else null, .message = json.written() }, │ │500 null, │ │501 .{ .kind = .head, .name = "haxy/other" }, │ │502 ); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │510 { │ │511 var result = try repo.switchDir(io, allocator, .{ .target = .{ .ref = .{ .kind = .head, .name = "haxy/meta" } } }); │ │512 defer result.deinit(); │ │529 - │ │530 - const head = (try repo.readRef(io, .{ .kind = .head, .name = "haxy/meta" })).?; │ │531 - try std.testing.expectEqualStrings(&std.fmt.bytesToHex(events[0].oid, .lower), &head); │ │513 │ │514 var merge = try repo.merge(io, allocator, .{ .kind = .full, .action = .{ .new = .{ .source = &.{.{ .ref = .{ .kind = .head, .name = "haxy/other" } }} } } }, null);│ │515 defer merge.deinit(); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │516 │ │517 try std.testing.expect(.success == merge.result); │ │518 } │ │538 - │ │539 - // │ │540 - // read and parse all of the events from the repo │ │541 - // │ │542 - │ │543 - const events2 = try readEventsFromRepo(Repo, repo_opts.hash, io, &arena, &repo, "haxy/meta");│ │519 │ │520 // │ │521 // consume events into the database │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │522 // │ │523 │ │524 { │ │550 - try evt.consume(repo_opts, io, allocator, &repo, events2); │ │525 + try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │526 │ │527 const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly());│ │528 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │574 │ │575 try std.testing.expectEqualStrings(other_events_to_consume[0].data.issue.description, first_issue.issue.description);│ │576 try std.testing.expectEqualStrings(other_events_to_consume[0].data.issue.tags, first_issue.issue.tags); │ │602 - } │ │603 - } │ │604 -} │ │605 - │ │606 -fn readEventsFromRepo( │ │607 - comptime Repo: type, │ │608 - comptime hash_kind: hash.HashKind, │ │609 - io: std.Io, │ │610 - arena: *std.heap.ArenaAllocator, │ │611 - repo: *Repo, │ │612 - branch_name: []const u8, │ │613 -) ![]evt.RepoEvent(hash_kind) { │ │614 - const allocator = arena.allocator(); │ │615 - │ │616 - var events: std.ArrayList(evt.RepoEvent(hash_kind)) = .empty; │ │617 - │ │618 - const ref = try repo.readRef(io, .{ .kind = .head, .name = branch_name }) orelse return error.RefNotFound; │ │619 - var commit_iter = try repo.log(io, allocator, &.{ref}); │ │620 - │ │621 - // read the message from each commit │ │622 - while (try commit_iter.next()) |commit_object| { │ │623 - var oid: [hash.byteLen(hash_kind)]u8 = undefined; │ │624 - _ = try std.fmt.hexToBytes(&oid, &commit_object.oid); │ │625 - │ │626 - const parent_oids = commit_object.content.commit.metadata.parent_oids orelse return error.ParentOidsNotFound; │ │627 - │ │628 - if (parent_oids.len > 1) { │ │629 - // this is a merge commit │ │630 - try events.append(allocator, .{ .parent_oid = null, .oid = oid, .event = null }); │ │631 - } else { │ │632 - try commit_object.object_reader.seekTo(commit_object.content.commit.message_position); │ │633 - const message = try commit_object.object_reader.interface.allocRemaining(allocator, .unlimited); │ │634 - const event = try std.json.parseFromSliceLeaky(evt.Event, allocator, message, .{}); │ │635 - │ │636 - if (parent_oids.len == 0) { │ │637 - try events.append(allocator, .{ .parent_oid = null, .oid = oid, .event = event }); │ │638 - } else { │ │639 - var parent_oid: [hash.byteLen(hash_kind)]u8 = undefined; │ │640 - _ = try std.fmt.hexToBytes(&parent_oid, &parent_oids[0]); │ │641 - try events.append(allocator, .{ .parent_oid = parent_oid, .oid = oid, .event = event }); │ │642 - } │ │577 } │ │578 } │ │645 - │ │646 - return events.items; │ │579 } │ │580 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯