╭ changed ──────────────╮ │src/ui/Repo/Patches.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────╮ │35 attachments: []const Attachment.WithId = &.{},│ │36 draft: bool = false, │ │37 fork_oid: []const u8 = "", │ │38 - target_branch: []const u8 = "", │ │38 no_changes: bool = false, │ │39 fork_exists: bool = false, │ │40 }; │ ╰──────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────╮ │59 tags: ?FieldConflict = null, │ │60 status: ?FieldConflict = null, │ │61 revision: ?FieldConflict = null, │ │62 + target_branch: ?FieldConflict = null, │ │63 description: ?struct { │ │64 chunks: []const diff3.Chunk, │ │65 ours_author: ui.Author = .unknown,│ ╰──────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────╮ │84 │ │85 // "owner/name", so the view can build /repo/owner/name/patches/... links. │ │86 identity: []const u8, │ │87 +default_target_branch: []const u8 = "", │ │88 // the url-encoded tag the lists are filtered to ("" = unfiltered). │ │89 tag: []const u8, │ │90 // the hex event id of the patch its status's window is rooted at ("" = the│ ╰───────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │176 title: []const u8, │ │177 tags: []const u8, │ │178 description: []const u8, │ │179 + target_branch: []const u8, │ │180 ) ![evt.event_id_size * 2]u8 { │ │181 if (!evt.Patch.fieldsValid(title, tags)) return error.InvalidFields;│ │182 const io = session.io orelse return error.NotFound; │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │184 const admin_repo = session.admin_repo orelse return error.NotFound; │ │185 const user_id = session.userId() orelse return error.NotFound; │ │186 const repo_id = data.repo_id orelse return error.NotFound; │ │187 + const repo_source = data.repo_source orelse return error.NotFound; │ │188 const author = (try session.eventAuthor()) orelse return error.NotFound; │ │189 + if (!try repo_source.hasBranch(io, allocator, target_branch)) return error.InvalidFields;│ │190 var id_bytes: [evt.event_id_size]u8 = undefined; │ │191 io.random(&id_bytes); │ │192 const id = std.fmt.bytesToHex(id_bytes, .lower); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │197 .title = title, │ │198 .description = description, │ │199 .tags = tags, │ │200 + .target_branch = target_branch, │ │201 .author = author, │ │202 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()),│ │203 }); │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │258 title: []const u8, │ │259 tags: []const u8, │ │260 description: []const u8, │ │261 + target_branch: []const u8, │ │262 ) !void { │ │263 const io = session.io orelse return error.NotFound; │ │264 const repos_dir = session.repos_dir orelse return error.NotFound;│ ╰──────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │265 const admin_repo = session.admin_repo orelse return error.NotFound; │ │266 const repo_id = data.repo_id orelse return error.NotFound; │ │267 + const repo_source = data.repo_source orelse return error.NotFound; │ │268 const user_id = session.userId() orelse return error.NotFound; │ │269 const patch_id = evt.parseEventId(id) catch return error.NotFound; │ │270 const author = (try session.eventAuthor()) orelse return error.NotFound;│ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │271 + if (!try repo_source.hasBranch(io, allocator, target_branch)) return error.InvalidFields;│ │272 │ │273 const id_hex = std.fmt.bytesToHex(patch_id, .lower); │ │274 const fork_path = try fork.forkPath(allocator, repos_dir, &id_hex); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │280 .title = title, │ │281 .tags = tags, │ │282 .description = description, │ │283 + .target_branch = target_branch, │ │284 .author = author, │ │285 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()),│ │286 })) return error.NotFound; │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯