╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ push.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
433 return err; 434 }; 435 436 if (!published) return response.finish(writer, null); 437 438 sideband.run(io, .{ .text = "Updating patches" }) catch {}; 439 sideband.run(io, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = 1 } }) catch {}; 440 441 // best-effort update the published patch so it has the new revision 442 var refreshed = false; 443 update: { 444 const revision_id = revision_id_maybe orelse break :update; 445 var update_arena = std.heap.ArenaAllocator.init(allocator); 446 defer update_arena.deinit(); 447 const target_update_moment = evt.currentMoment(repo_opts, target_repo) catch break :update; 448 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; 449 if (published_patch.removed) break :update; 450 const fork_update_moment = evt.currentMoment(repo_opts, fork_repo) catch break :update; 451 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; 452 if (revision.removed) break :update; 453 const selected = evt.Patch.Revision.fromRecord(revision_id, revision); 454 if (published_patch.event.revision) |current| { 455 if (evt.fieldEqual(evt.Patch.Revision, current, selected)) break :update; 456 } 457 var patch = published_patch.event; 458 patch.revision = selected; 459 evt.consume(.{ .server = server }, .repo, .xit, repo_opts, io, allocator, target_repo, evt.events_ref, &.{.{ 460 .id = id.*, 461 .timestamp = timestamp, 462 .author = author, 463 .event = .{ .patch = patch }, 464 }}) catch |update_err| { 465 serve_common.logError(io, error_writer, "failed to update published patch {s}: {s}\n", .{ id, @errorName(update_err) }); 466 break :update; 467 }; 468 // consume also refreshed mergeability 469 refreshed = true; 470 } 471 472 if (!refreshed) pch.refreshMergeability(repo_opts, io, allocator, target_repo, server.users_dir, patch_id); 473 sideband.run(io, .{ .complete_one = .writing_patch }) catch {}; 474 sideband.run(io, .{ .end = .writing_patch }) catch {}; 475 476 // the client may read either repo as soon as it gets the final response. 477 try response.finish(writer, null); 478 } 479