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