╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │467 │ │468 { │ │469 try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │585 - │ │586 - const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); │ │587 - │ │588 - // read the moment we just created │ │589 - const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │590 - const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │591 - │ │592 - // get the last object id │ │593 - const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound; │ │594 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │595 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │596 - │ │597 - const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │598 - const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │470 │ │600 - try std.testing.expectEqual(2, try haxy.count()); │ │471 + const haxy_moment = try evt.currentMoment(repo_opts, &repo); │ │472 │ │602 - const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │603 - const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │604 - │ │605 - const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; │ │606 - const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │607 - │ │473 // get the map of issues │ │474 const event_id_to_issue_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->issue")) orelse return error.NotFound;│ │475 const event_id_to_issue = try Repo.DB.HashMap(.read_only).init(event_id_to_issue_cursor); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │534 { │ │535 try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │536 │ │672 - const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); │ │537 + const haxy_moment = try evt.currentMoment(repo_opts, &repo); │ │538 │ │674 - // read the moment we just created │ │675 - const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │676 - const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │677 - │ │678 - // get the last object id │ │679 - const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound; │ │680 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │681 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │682 - │ │683 - const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │684 - const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │685 - │ │686 - try std.testing.expectEqual(1, try haxy.count()); │ │687 - │ │688 - const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │689 - const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │690 - │ │691 - const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; │ │692 - const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │693 - │ │539 // get the map of issues │ │540 const event_id_to_issue_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->issue")) orelse return error.NotFound;│ │541 const event_id_to_issue = try Repo.DB.HashMap(.read_only).init(event_id_to_issue_cursor); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │706 }, │ │707 }, │ │708 }; │ │864 - │ │865 - // │ │866 - // insert users and repos as commits in the repo │ │867 - // │ │868 - │ │869 - { │ │870 - var json: std.Io.Writer.Allocating = .init(allocator); │ │871 - defer json.deinit(); │ │709 │ │873 - for (events_to_consume) |event| { │ │874 - json.clearRetainingCapacity(); │ │875 - │ │876 - try std.json.Stringify.value(event, .{}, &json.writer); │ │877 - │ │878 - // commit the event into a special branch │ │879 - _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" }); │ │880 - } │ │881 - } │ │882 - │ │883 - // │ │884 - // consume events into the database │ │885 - // │ │710 + // commit and consume the seed events │ │711 + try evt.commitAndConsume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }, &events_to_consume); │ │712 │ │713 { │ │888 - try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │889 - │ │890 - const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); │ │891 - │ │892 - // read the moment we just created │ │893 - const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │894 - const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │895 - │ │896 - // get the last object id │ │897 - const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound; │ │898 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │899 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │900 - │ │901 - const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │902 - const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │903 - │ │904 - try std.testing.expectEqual(1, try haxy.count()); │ │905 - │ │906 - const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │907 - const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │908 - │ │909 - const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; │ │910 - const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │714 + const haxy_moment = try evt.currentMoment(repo_opts, &repo); │ │715 │ │716 // get the map of users │ │717 const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->user")) orelse return error.NotFound;│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 759 .event = .{ .repo = null }, │ │ 760 }, │ │ 761 }; │ │ 958 - │ │ 959 - { │ │ 960 - var json: std.Io.Writer.Allocating = .init(allocator); │ │ 961 - defer json.deinit(); │ │ 962 - │ │ 963 - for (events_to_consume2) |event| { │ │ 964 - json.clearRetainingCapacity(); │ │ 965 - │ │ 966 - try std.json.Stringify.value(event, .{}, &json.writer); │ │ 967 - │ │ 968 - // commit the event into a special branch │ │ 969 - _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" }); │ │ 970 - } │ │ 971 - } │ │ 762 │ │ 973 - // │ │ 974 - // consume the removal into the database │ │ 975 - // │ │ 763 + // commit and consume the removal │ │ 764 + try evt.commitAndConsume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }, &events_to_consume2); │ │ 765 │ │ 766 { │ │ 978 - try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │ 979 - │ │ 980 - const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); │ │ 981 - │ │ 982 - // read the moment we just created │ │ 983 - const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │ 984 - const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │ 985 - │ │ 986 - // get the last object id │ │ 987 - const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound; │ │ 988 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │ 989 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │ 990 - │ │ 991 - const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │ 992 - const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │ 993 - │ │ 994 - try std.testing.expectEqual(2, try haxy.count()); │ │ 767 + const haxy_moment = try evt.currentMoment(repo_opts, &repo); │ │ 768 │ │ 996 - const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │ 997 - const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │ 998 - │ │ 999 - const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; │ │1000 - const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │1001 - │ │ 769 // get the map of repos │ │ 770 const event_id_to_repo_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->repo")) orelse return error.NotFound;│ │ 771 const event_id_to_repo = try Repo.DB.HashMap(.read_only).init(event_id_to_repo_cursor); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 793 .event = .{ .user = null }, │ │ 794 }, │ │ 795 }; │ │1029 - │ │1030 - { │ │1031 - var json: std.Io.Writer.Allocating = .init(allocator); │ │1032 - defer json.deinit(); │ │1033 - │ │1034 - for (events_to_consume3) |event| { │ │1035 - json.clearRetainingCapacity(); │ │ 796 │ │1037 - try std.json.Stringify.value(event, .{}, &json.writer); │ │1038 - │ │1039 - // commit the event into a special branch │ │1040 - _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" }); │ │1041 - } │ │1042 - } │ │ 797 + // commit and consume the removal │ │ 798 + try evt.commitAndConsume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }, &events_to_consume3); │ │ 799 │ │1044 - // │ │1045 - // consume the user removal into the database │ │1046 - // │ │1047 - │ │ 800 { │ │1049 - try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │1050 - │ │1051 - const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); │ │1052 - │ │1053 - // read the moment we just created │ │1054 - const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │1055 - const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │1056 - │ │1057 - // get the last object id │ │1058 - const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound; │ │1059 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │1060 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │ 801 + const haxy_moment = try evt.currentMoment(repo_opts, &repo); │ │ 802 │ │1062 - const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │1063 - const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │1064 - │ │1065 - try std.testing.expectEqual(3, try haxy.count()); │ │1066 - │ │1067 - const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │1068 - const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │1069 - │ │1070 - const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; │ │1071 - const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │1072 - │ │ 803 // get the map of users │ │ 804 const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->user")) orelse return error.NotFound;│ │ 805 const event_id_to_user = try Repo.DB.HashMap(.read_only).init(event_id_to_user_cursor); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────╮ │808 }│ │809 } │ │810 │ │811 + │ ╰──────────╯ ╭ changed ──╮ │src/try.zig│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │43 const work_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "server", "admin" });│ │44 defer allocator.free(work_path); │ │45 │ │46 - const repo_opts: rp.RepoOpts(.xit) = .{ .is_test = true }; │ │46 + const repo_opts: rp.RepoOpts(.xit) = .{}; │ │47 const Repo = rp.Repo(.xit, repo_opts); │ │48 var repo = try Repo.init(io, allocator, .{ .path = work_path }); │ │49 defer repo.deinit(io, allocator); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────╮ │50 + │ │51 + try repo.addConfig(io, allocator, .{ .name = "user.name", .value = "haxy" }); │ │52 + try repo.addConfig(io, allocator, .{ .name = "user.email", .value = "admin@haxy" });│ │53 │ │54 var session: ui.Session = undefined; │ │55 │ ╰────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │170 }, │ │171 }, │ │172 }; │ │170 - } │ │171 - │ │172 - // insert users and repos as commits in the repo │ │173 - { │ │174 - var json: std.Io.Writer.Allocating = .init(allocator); │ │175 - defer json.deinit(); │ │176 - │ │177 - for (events_to_consume) |event| { │ │178 - json.clearRetainingCapacity(); │ │179 - │ │180 - try std.json.Stringify.value(event, .{}, &json.writer); │ │181 - │ │182 - // commit the event into a special branch │ │183 - _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" });│ │184 - } │ │173 } │ │174 │ │187 - // consume events into the database │ │188 - try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); │ │175 + // commit the seed events and consume them into the database │ │176 + try evt.commitAndConsume(repo_opts, io, allocator, &repo, evt.events_ref, &events_to_consume); │ │177 │ │178 session = try ui.Session.init(repo_opts, &page_arena, &repo, .{}); │ │179 break :blk .{ .home = try .init(repo_opts, &page_arena, session.haxy_moment orelse unreachable) }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────────────────────────╮ │1 const std = @import("std"); │ │2 const xit = @import("xit"); │ │3 const rp = xit.repo; │ │4 -const hash = xit.hash; │ │4 const xitui = xit.xitui; │ │5 const term = xitui.terminal;│ │6 const wgt = xitui.widget; │ ╰───────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯