╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ push.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
343 .timestamp = timestamp, 344 .newest = newest, 345 .revision_id_maybe = &revision_id_maybe, 346 }); 347 }; 348 result catch |err| { 349 response.finish(writer, @errorName(err)) catch {}; 350 if (err == error.CancelTransaction) return; 351 return err; 352 }; 353 354 find.refresh(repo_opts, io, allocator, fork_repo) catch |err| { 355 serve_common.logError(io, error_writer, "failed to refresh file index: {s}\n", .{@errorName(err)}); 356 }; 357 if (!published) return response.finish(writer, null); 358 359 var progress = PushProgress{ .response = &response, .writer = writer, .label = "Updating patches" }; 360 progress.run(io, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = 1 } }) catch {}; 361 362 // best-effort update the published patch so it has the new revision 363 var refreshed = false; 364 update: { 365 const revision_id = revision_id_maybe orelse break :update; 366 var update_arena = std.heap.ArenaAllocator.init(allocator); 367 defer update_arena.deinit(); 368 const target_update_moment = evt.currentMoment(repo_opts, target_repo) catch break :update; 369 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; 370 if (published_patch.removed) break :update; 371 const fork_update_moment = evt.currentMoment(repo_opts, fork_repo) catch break :update; 372 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; 373 if (revision.removed) break :update; 374 const selected = evt.Patch.Revision.fromRecord(revision_id, revision); 375 if (published_patch.event.revision) |current| { 376 if (evt.fieldEqual(evt.Patch.Revision, current, selected)) break :update; 377 } 378 var patch = published_patch.event; 379 patch.revision = selected; 380 evt.consume(.server, .repo, .xit, repo_opts, io, allocator, target_repo, evt.events_ref, &.{.{ 381 .id = id.*, 382 .timestamp = timestamp, 383 .author = author, 384 .event = .{ .patch = patch }, 385 }}) catch |update_err| { 386 serve_common.logError(io, error_writer, "failed to update published patch {s}: {s}\n", .{ id, @errorName(update_err) }); 387 break :update; 388 }; 389 // consume also refreshed mergeability 390 refreshed = true; 391 } 392 393 if (!refreshed) pch.refreshMergeability(repo_opts, io, allocator, target_repo, patch_id); 394 progress.run(io, .{ .complete_one = .writing_patch }) catch {}; 395 progress.run(io, .{ .end = .writing_patch }) catch {}; 396 397 // the client may read either repo as soon as it gets the final response. 398 try response.finish(writer, null); 399 } 400