╭ changed ───╮ │src/push.zig│ ╰────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │68 } │ │69 var progress = PushProgress{ .response = response, .writer = writer }; │ │70 try xit.patch.writePatches(repo_opts, state, io, allocator, &iter, &progress); │ │71 +} │ │72 + │ │73 +fn writeUndo( │ │74 + comptime repo_opts: rp.RepoOpts(.xit), │ │75 + state: rp.Repo(.xit, repo_opts).State(.read_write), │ │76 + io: std.Io, │ │77 + allocator: std.mem.Allocator, │ │78 + author: ?evt.CommitAuthor, │ │79 +) !void { │ │80 + var author_json: std.json.ObjectMap = if (author) |user| │ │81 + try .init(allocator, &.{ "username", "email" }, &.{ .{ .string = user.name }, .{ .string = user.email } }) │ │82 + else │ │83 + .empty; │ │84 + defer author_json.deinit(allocator); │ │85 + var payload: std.json.ObjectMap = try .init(allocator, &.{"author"}, &.{if (author != null) .{ .object = author_json } else .null}); │ │86 + defer payload.deinit(allocator); │ │87 + try xit.undo.write(repo_opts, state, std.Io.Timestamp.now(io, .real).toSeconds(), .{ .custom = .{ .action = "push", .payload = payload } });│ │88 } │ │89 │ │90 // serve a receive-pack and consume any events it pushed to the events branch, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │ 98 reader: *std.Io.Reader, │ │ 99 writer: *std.Io.Writer, │ │100 options: xit.net_server_receive_pack.Options,│ │101 + author: ?evt.CommitAuthor, │ │102 repo_root_path: []const u8, │ │103 error_writer: *std.Io.Writer, │ │104 ) !void { │ ╰──────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────╮ │118 reader: *std.Io.Reader, │ │119 writer: *std.Io.Writer, │ │120 options: xit.net_server_receive_pack.Options, │ │121 + author: ?evt.CommitAuthor, │ │122 response: *xit.net_server_receive_pack.Response,│ │123 repo_root_path: []const u8, │ │124 error_writer: *std.Io.Writer, │ ╰─────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │140 _ = try evt.consumeInTransaction(.repo, .xit, repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, evt.events_ref); │ │141 try pch.detectMerged(repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, ctx.repo_root_path, ctx.updates.items.items, ctx.error_writer);│ │142 } │ │124 - try xit.undo.writeMessage(repo_opts, state, .push); │ │143 + try writeUndo(repo_opts, state, ctx.io, ctx.allocator, ctx.author); │ │144 } │ │145 }; │ │146 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │159 .reader = reader, │ │160 .writer = writer, │ │161 .options = options, │ │162 + .author = author, │ │163 .response = &response, │ │164 .repo_root_path = repo_root_path,│ │165 .error_writer = error_writer, │ ╰──────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │318 try evt.commitEvents(.xit, repo_opts, state, ctx.io, ctx.allocator, evt.events_ref, events[0..event_count], null); │ │319 if (!try evt.consumeInTransaction(.fork, .xit, repo_opts, state, &ctx.core.db, &moment, ctx.io, ctx.allocator, evt.events_ref)) return error.CancelTransaction;│ │320 } │ │301 - try xit.undo.writeMessage(repo_opts, state, .push); │ │321 + try writeUndo(repo_opts, state, ctx.io, ctx.allocator, ctx.author); │ │322 } │ │323 }; │ │324 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯