╭ changed ───╮ │src/push.zig│ ╰────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────╮ │13 pub const PushProgress = struct { │ │14 response: *xit.net_server_receive_pack.Response,│ │15 writer: *std.Io.Writer, │ │16 + label: []const u8 = "Processing commits", │ │17 count: usize = 0, │ │18 total: usize = 0, │ │19 │ ╰────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │33 }, │ │34 else => return, │ │35 } │ │36 + if (self.total == 0) return; │ │37 var buffer: [128]u8 = undefined; │ │36 - const percent = if (self.total == 0) 100 else @as(u128, self.count) * 100 / self.total; │ │37 - const text = try std.fmt.bufPrint(&buffer, "Processing commits: {d}% ({d}/{d}){s}", .{ percent, self.count, self.total, if (event == .end) "\n" else "\r" });│ │38 + const percent = @as(u128, self.count) * 100 / self.total; │ │39 + const text = try std.fmt.bufPrint(&buffer, "{s}: {d}% ({d}/{d}){s}", .{ self.label, percent, self.count, self.total, if (event == .end) "\n" else "\r" }); │ │40 try self.response.progress(self.writer, text); │ │41 } │ │42 }; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │51 response: *xit.net_server_receive_pack.Response, │ │52 writer: *std.Io.Writer, │ │53 ) !void { │ │52 - try response.progress(writer, "Processing commits...\n"); │ │54 var config = try xit.config.Config(.xit, repo_opts).init(state.readOnly(), io, allocator);│ │55 defer config.deinit(); │ │56 try config.add(state, io, .{ .name = "merge.algorithm", .value = "patch" }); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │150 return err; │ │151 }; │ │152 │ │152 - pch.refreshBranches(.server, .xit, repo_opts, io, allocator, repo, updates.items.items) catch |err| { │ │153 + var progress = PushProgress{ .response = &response, .writer = writer, .label = "Updating patches" }; │ │154 + pch.refreshBranches(.server, .xit, repo_opts, io, allocator, repo, updates.items.items, &progress) catch |err| {│ │155 serve_common.logError(io, error_writer, "failed to refresh branch patches: {s}\n", .{@errorName(err)}); │ │156 + pch.refreshMergeability(repo_opts, io, allocator, repo, null); │ │157 }; │ │155 - response.progress(writer, "Checking merges...\n") catch {}; │ │156 - pch.refreshMergeability(repo_opts, io, allocator, repo, null); │ │158 try response.finish(writer, null); │ │159 } │ │160 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │323 return err; │ │324 }; │ │325 │ │325 - response.progress(writer, "Checking merges...\n") catch {}; │ │326 + var progress = PushProgress{ .response = &response, .writer = writer, .label = "Updating patches" };│ │327 + progress.run(io, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = 1 } }) catch {}; │ │328 │ │329 // best-effort update the published patch so it has the new revision │ │330 + var refreshed = false; │ │331 update: { │ │332 const revision_id = revision_id_maybe orelse break :update; │ │333 if (!published) break :update; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │354 serve_common.logError(io, error_writer, "failed to update published patch {s}: {s}\n", .{ id, @errorName(update_err) });│ │355 break :update; │ │356 }; │ │354 - // consume refreshed the published patch before acknowledging the push │ │355 - return response.finish(writer, null); │ │357 + // consume also refreshed mergeability │ │358 + refreshed = true; │ │359 } │ │360 │ │358 - pch.refreshMergeability(repo_opts, io, allocator, target_repo, patch_id); │ │361 + if (!refreshed) pch.refreshMergeability(repo_opts, io, allocator, target_repo, patch_id); │ │362 + progress.run(io, .{ .complete_one = .writing_patch }) catch {}; │ │363 + progress.run(io, .{ .end = .writing_patch }) catch {}; │ │364 │ │365 // the client may read either repo as soon as it gets the final response. │ │366 try response.finish(writer, null); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯