╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │895 ) !void { │ │896 const comment_id = parts.comment_id orelse return error.NotFound; │ │897 const thread_id = std.fmt.bytesToHex(parts.thread_id, .lower); │ │967 - switch (host) { │ │968 - .remote => |remote| { │ │969 - const repo_prefix = "/repo/"; │ │970 - if (!std.mem.startsWith(u8, parts.repo_base, repo_prefix)) return error.NotFound; │ │971 - const repos_dir = try std.fs.path.join(allocator, &.{ std.fs.path.dirname(remote.admin_repo_path) orelse ".", "repos" }); │ │972 - defer allocator.free(repos_dir); │ │973 - const repo_path = switch (try serve_common.resolveRepoPath(io, allocator, repos_dir, remote.admin_repo_path, parts.repo_base[repo_prefix.len..], false)) {│ │974 - .ok => |p| p, │ │975 - .invalid, .not_found => return error.NotFound, │ │976 - }; │ │977 - defer allocator.free(repo_path); │ │978 - │ │979 - var repo = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = repo_path }); │ │980 - defer repo.deinit(io, allocator); │ │981 - try evt.Comment.update(.xit, .{}, io, allocator, &repo, &thread_id, &comment_id, body, author); │ │982 - }, │ │983 - .local => |src| { │ │984 - if (parts.repo_base.len != 0) return error.NotFound; │ │985 - switch (src.repo_kind) { │ │986 - inline else => |repo_kind| { │ │987 - var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); │ │988 - defer any_repo.deinit(io, allocator); │ │989 - switch (any_repo) { │ │990 - inline else => |*repo| try evt.Comment.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &comment_id, body, author), │ │991 - } │ │992 - }, │ │898 + const request_repo = (try requestRepoSource(io, allocator, host, parts.repo_base)) orelse return error.NotFound; │ │899 + defer request_repo.deinit(allocator); │ │900 + const source = request_repo.source; │ │901 + switch (source.repo_kind) { │ │902 + inline else => |repo_kind| { │ │903 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, source.localInitOpts()); │ │904 + defer any_repo.deinit(io, allocator); │ │905 + switch (any_repo) { │ │906 + inline else => |*repo| try evt.Comment.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &comment_id, body, author), │ │907 } │ │908 }, │ │909 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1018 defer author_arena.deinit(); │ │1019 const author = (try eventAuthor(io, allocator, &author_arena, request, host)) orelse return respondLoginRequired(request); │ │1020 │ │1107 - switch (host) { │ │1108 - .remote => |remote| { │ │1109 - const repo_prefix = "/repo/"; │ │1110 - if (!std.mem.startsWith(u8, parts.repo_base, repo_prefix)) return respondRemoveNotFound(request); │ │1111 - const repos_dir = try std.fs.path.join(allocator, &.{ std.fs.path.dirname(remote.admin_repo_path) orelse ".", "repos" }); │ │1112 - defer allocator.free(repos_dir); │ │1113 - const repo_path = switch (try serve_common.resolveRepoPath(io, allocator, repos_dir, remote.admin_repo_path, parts.repo_base[repo_prefix.len..], false)) { │ │1114 - .ok => |p| p, │ │1115 - .invalid, .not_found => return respondRemoveNotFound(request), │ │1116 - }; │ │1117 - defer allocator.free(repo_path); │ │1118 - │ │1119 - var repo = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = repo_path }); │ │1120 - defer repo.deinit(io, allocator); │ │1121 - evt.remove(.xit, .{}, io, allocator, &repo, &parts.id, parts.kind, author) catch |err| switch (err) { │ │1122 - error.EventNotFound => return respondRemoveNotFound(request), │ │1123 - else => |e| return e, │ │1124 - }; │ │1125 - }, │ │1126 - .local => |src| { │ │1127 - if (parts.repo_base.len != 0) return respondRemoveNotFound(request); │ │1128 - switch (src.repo_kind) { │ │1129 - inline else => |repo_kind| { │ │1130 - var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); │ │1131 - defer any_repo.deinit(io, allocator); │ │1132 - switch (any_repo) { │ │1133 - inline else => |*repo| evt.remove(repo_kind, repo.self_repo_opts, io, allocator, repo, &parts.id, parts.kind, author) catch |err| switch (err) {│ │1134 - error.EventNotFound => return respondRemoveNotFound(request), │ │1135 - else => |e| return e, │ │1136 - }, │ │1137 - } │ │1021 + const request_repo = (try requestRepoSource(io, allocator, host, parts.repo_base)) orelse return respondRemoveNotFound(request); │ │1022 + defer request_repo.deinit(allocator); │ │1023 + const source = request_repo.source; │ │1024 + switch (source.repo_kind) { │ │1025 + inline else => |repo_kind| { │ │1026 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, source.localInitOpts()); │ │1027 + defer any_repo.deinit(io, allocator); │ │1028 + switch (any_repo) { │ │1029 + inline else => |*repo| evt.remove(repo_kind, repo.self_repo_opts, io, allocator, repo, &parts.id, parts.kind, author) catch |err| switch (err) { │ │1030 + error.EventNotFound => return respondRemoveNotFound(request), │ │1031 + else => |e| return e, │ │1032 }, │ │1033 } │ │1034 }, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1062 update: evt.Issue.Update, │ │1063 author: evt.CommitAuthor, │ │1064 ) !void { │ │1171 - switch (host) { │ │1172 - .remote => |remote| { │ │1173 - const repo_prefix = "/repo/"; │ │1174 - if (!std.mem.startsWith(u8, parts.repo_base, repo_prefix)) return error.NotFound; │ │1175 - const repos_dir = try std.fs.path.join(allocator, &.{ std.fs.path.dirname(remote.admin_repo_path) orelse ".", "repos" }); │ │1176 - defer allocator.free(repos_dir); │ │1177 - const repo_path = switch (try serve_common.resolveRepoPath(io, allocator, repos_dir, remote.admin_repo_path, parts.repo_base[repo_prefix.len..], false)) {│ │1178 - .ok => |p| p, │ │1179 - .invalid, .not_found => return error.NotFound, │ │1180 - }; │ │1181 - defer allocator.free(repo_path); │ │1182 - │ │1183 - var repo = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = repo_path }); │ │1184 - defer repo.deinit(io, allocator); │ │1185 - try evt.Issue.update(.xit, .{}, io, allocator, &repo, &parts.id_bytes, update, author); │ │1186 - }, │ │1187 - .local => |src| { │ │1188 - // the local forms post to "/issue:<id>/...", so the repo base │ │1189 - // is empty │ │1190 - if (parts.repo_base.len != 0) return error.NotFound; │ │1191 - switch (src.repo_kind) { │ │1192 - inline else => |repo_kind| { │ │1193 - var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); │ │1194 - defer any_repo.deinit(io, allocator); │ │1195 - switch (any_repo) { │ │1196 - inline else => |*repo| try evt.Issue.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &parts.id_bytes, update, author), │ │1197 - } │ │1198 - }, │ │1065 + const request_repo = (try requestRepoSource(io, allocator, host, parts.repo_base)) orelse return error.NotFound; │ │1066 + defer request_repo.deinit(allocator); │ │1067 + const source = request_repo.source; │ │1068 + switch (source.repo_kind) { │ │1069 + inline else => |repo_kind| { │ │1070 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, source.localInitOpts()); │ │1071 + defer any_repo.deinit(io, allocator); │ │1072 + switch (any_repo) { │ │1073 + inline else => |*repo| try evt.Issue.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &parts.id_bytes, update, author), │ │1074 } │ │1075 }, │ │1076 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1087 description: []const u8, │ │1088 author: evt.CommitAuthor, │ │1089 ) !void { │ │1215 - switch (host) { │ │1216 - .remote => |remote| { │ │1217 - const repo_prefix = "/repo/"; │ │1218 - if (!std.mem.startsWith(u8, repo_base, repo_prefix)) return error.NotFound; │ │1219 - const repos_dir = try std.fs.path.join(allocator, &.{ std.fs.path.dirname(remote.admin_repo_path) orelse ".", "repos" }); │ │1220 - defer allocator.free(repos_dir); │ │1221 - const repo_path = switch (try serve_common.resolveRepoPath(io, allocator, repos_dir, remote.admin_repo_path, repo_base[repo_prefix.len..], false)) { │ │1222 - .ok => |p| p, │ │1223 - .invalid, .not_found => return error.NotFound, │ │1224 - }; │ │1225 - defer allocator.free(repo_path); │ │1226 - │ │1227 - var repo = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = repo_path }); │ │1228 - defer repo.deinit(io, allocator); │ │1229 - try evt.Discussion.update(.xit, .{}, io, allocator, &repo, id, title, tags, description, author); │ │1230 - }, │ │1231 - .local => |src| { │ │1232 - if (repo_base.len != 0) return error.NotFound; │ │1233 - switch (src.repo_kind) { │ │1234 - inline else => |repo_kind| { │ │1235 - var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); │ │1236 - defer any_repo.deinit(io, allocator); │ │1237 - switch (any_repo) { │ │1238 - inline else => |*repo| try evt.Discussion.update(repo_kind, repo.self_repo_opts, io, allocator, repo, id, title, tags, description, author),│ │1239 - } │ │1240 - }, │ │1090 + const request_repo = (try requestRepoSource(io, allocator, host, repo_base)) orelse return error.NotFound; │ │1091 + defer request_repo.deinit(allocator); │ │1092 + const source = request_repo.source; │ │1093 + switch (source.repo_kind) { │ │1094 + inline else => |repo_kind| { │ │1095 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, source.localInitOpts()); │ │1096 + defer any_repo.deinit(io, allocator); │ │1097 + switch (any_repo) { │ │1098 + inline else => |*repo| try evt.Discussion.update(repo_kind, repo.self_repo_opts, io, allocator, repo, id, title, tags, description, author), │ │1099 } │ │1100 }, │ │1101 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯