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