╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2654 }, │ │2655 else => |other| return other, │ │2656 }; │ │2657 + if (comptime kind == .patch and repo_kind == .xit) { │ │2658 + if (!self.session.data.is_local) pch.refreshMergeability(repo.self_repo_opts, io, allocator, repo, id_bytes);│ │2659 + } │ │2660 } else if (has_status) │ │2661 try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ │ │2662 .title = title, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2703 .merge => if (comptime supports_merge) { │ │2704 if (comptime wasm) return; │ │2705 const entry = self.data.selectedThread() orelse return; │ │2678 - try self.data.mergePatch(self.session, allocator, entry.id, button_index > 1); │ │2706 + const revision: pch.MergeRevision = if (button_index > 1) .squash else .source; │ │2707 + if (!Data.canMerge(entry.*, self.session) or entry.mergeability.get(revision) != .clean) return; │ │2708 + self.data.mergePatch(self.session, allocator, entry.id, revision) catch |err| switch (err) { │ │2709 + error.MergeConflict, error.MergeCheckUnavailable, error.PatchOutOfDate, error.PatchDataUnavailable => {│ │2710 + const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; │ │2711 + try self.session.navigate(route); │ │2712 + return; │ │2713 + }, │ │2714 + else => return err, │ │2715 + }; │ │2716 const merged = std.meta.stringToEnum(Status, "merged") orelse return; │ │2717 const route = listRoute(self.data.identity, merged, "", entry.id) orelse return; │ │2718 try self.session.navigate(route); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │790 const id = std.fmt.bytesToHex(parts.thread_id, .lower); │ │791 const repos_dir = try std.fs.path.join(allocator, &.{ std.fs.path.dirname(remote.admin_repo_path) orelse ".", "repos" });│ │792 defer allocator.free(repos_dir); │ │793 - try pch.mergeAndRemoveFork(.{}, io, allocator, repos_dir, &admin_repo, &target_repo, .{ │ │793 + pch.mergeAndRemoveFork(.{}, io, allocator, repos_dir, &admin_repo, &target_repo, .{ │ │794 .id = id, │ │795 .revision = revision, │ │796 .author = author, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │797 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), │ │798 - }); │ │798 + }) catch |err| switch (err) { │ │799 + error.MergeConflict => return request.respond("merge conflict", .{ │ │800 + .status = .conflict, │ │801 + .keep_alive = false, │ │802 + .extra_headers = &.{.{ .name = "content-type", .value = "text/plain" }}, │ │803 + }), │ │804 + error.MergeCheckUnavailable, error.PatchOutOfDate, error.PatchDataUnavailable => {}, │ │805 + else => return err, │ │806 + }; │ │807 │ │808 const location = try std.fmt.allocPrint(allocator, "{s}/patch:{s}", .{ parts.repo_base, &id });│ │809 defer allocator.free(location); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1199 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, source.localInitOpts()); │ │1200 defer any_repo.deinit(io, allocator); │ │1201 switch (any_repo) { │ │1194 - inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, id, update, author),│ │1202 + inline else => |*repo| { │ │1203 + try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, id, update, author); │ │1204 + if (comptime Event == evt.Patch and repo_kind == .xit) { │ │1205 + if (host == .remote) pch.refreshMergeability(repo.self_repo_opts, io, allocator, repo, id.*); │ │1206 + } │ │1207 + }, │ │1208 } │ │1209 }, │ │1210 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯