╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ push.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
400 var refreshed = false; 401 update: { 402 const revision_id = revision_id_maybe orelse break :update; 403 var update_arena = std.heap.ArenaAllocator.init(allocator); 404 defer update_arena.deinit(); 405 const target_update_moment = evt.currentMoment(repo_opts, target_repo) catch break :update; 406 const published_patch = (evt.Patch.readById(evt.EventDB(repo_opts.hash), repo_opts.hash, target_update_moment, &update_arena, &patch_id) catch break :update) orelse break :update; 407 if (published_patch.removed) break :update; 408 const fork_update_moment = evt.currentMoment(repo_opts, fork_repo) catch break :update; 409 const revision = (evt.PatchRev.readById(evt.EventDB(repo_opts.hash), repo_opts.hash, fork_update_moment, &update_arena, &revision_id) catch break :update) orelse break :update; 410 if (revision.removed) break :update; 411 const selected = evt.Patch.Revision.fromRecord(revision_id, revision); 412 if (published_patch.event.revision) |current| { 413 if (evt.fieldEqual(evt.Patch.Revision, current, selected)) break :update; 414 } 415 var patch = published_patch.event; 416 patch.revision = selected; 417 evt.consume(.{ .server = server }, .repo, .xit, repo_opts, io, allocator, target_repo, evt.events_ref, &.{.{ 418 .id = id.*, 419 .timestamp = timestamp, 420 .author = author, 421 .event = .{ .patch = patch }, 422 }}) catch |update_err| { 423 serve_common.logError(io, error_writer, "failed to update published patch {s}: {s}\n", .{ id, @errorName(update_err) }); 424 break :update; 425 }; 426 // consume also refreshed mergeability 427 refreshed = true; 428 } 429 430 if (!refreshed) pch.refreshMergeability(repo_opts, io, allocator, target_repo, server.users_dir, patch_id); 431 sideband.run(io, .{ .complete_one = .writing_patch }) catch {}; 432 sideband.run(io, .{ .end = .writing_patch }) catch {}; 433 434 // the client may read either repo as soon as it gets the final response. 435 try response.finish(writer, null); 436 } 437