╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ───────╮ │src/test/net.zig│ ╰────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │659 defer arena.deinit(); │ │660 const moment = try evt.currentMoment(.{}, &target); │ │661 const patch = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &arena, &fork_id)) orelse return error.NotFound; │ │662 - try evt.consume(.repo, .xit, .{}, io, allocator, &target, evt.events_ref, &.{.{ │ │663 - .id = fork_id_hex, │ │664 - .timestamp = 3, │ │665 - .author = .{ .name = "admin", .email = "admin@example.test" }, │ │666 - .event = .{ .patch = .{ │ │667 - .title = "edited feature", │ │668 - .description = patch.event.description, │ │669 - .tags = patch.event.tags, │ │670 - .target_patch_id = patch.event.target_patch_id, │ │671 - .revision = patch.event.revision, │ │672 - } }, │ │673 - }}); │ │662 + try evt.Patch.update(.xit, .{}, io, allocator, &target, &fork_id, .{ .fields = .{ │ │663 + .title = "edited feature", │ │664 + .description = patch.event.description, │ │665 + .tags = patch.event.tags, │ │666 + .target_branch = "feature", │ │667 + } }, .{ .name = "admin", .email = "admin@example.test" }); │ │668 } │ │669 │ │676 - const feature_remote_url = try std.fmt.allocPrint(allocator, "git@localhost:fork/admin/target/patch:{s}/branch:feature", .{&fork_id_hex});│ │670 + const feature_remote_url = try std.fmt.allocPrint(allocator, "git@localhost:fork/admin/target/patch:{s}", .{&fork_id_hex}); │ │671 defer allocator.free(feature_remote_url); │ │672 try client.addRemote(io, allocator, .{ .name = "patch-to-feature", .value = feature_remote_url }); │ │673 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │695 @memcpy(&second_patch_oid, newest.record.patch_oid); │ │696 try std.testing.expect(!std.mem.eql(u8, &first_revision_id, &second_revision_id)); │ │697 try std.testing.expectEqualStrings(&second_source_oid, newest.record.event.source_oid); │ │704 - try std.testing.expectEqualStrings("refs/heads/feature", newest.record.event.target_ref);│ │698 try std.testing.expectEqualStrings("edited feature", newest.record.event.message); │ │699 } │ │700 { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │708 const selected = patch.event.revision orelse return error.NotFound; │ │709 try std.testing.expectEqualStrings(&std.fmt.bytesToHex(second_revision_id, .lower), &selected.id);│ │710 try std.testing.expectEqualStrings(&second_source_oid, selected.source_oid); │ │718 - try std.testing.expectEqualStrings("refs/heads/feature", selected.target_ref); │ │711 + try std.testing.expectEqualStrings("feature", patch.event.target_branch); │ │712 } │ │713 │ │714 // │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │797 try std.testing.expectEqualStrings(&second_patch_oid, imported.patch_oid); │ │798 } │ │799 │ │807 - const other_url = try std.fmt.allocPrint(allocator, "git@localhost:fork/admin/other/patch:{s}/branch:other", .{&fork_id_hex}); │ │800 + const other_url = try std.fmt.allocPrint(allocator, "git@localhost:fork/admin/other/patch:{s}", .{&fork_id_hex}); │ │801 defer allocator.free(other_url); │ │802 try client.addRemote(io, allocator, .{ .name = "other", .value = other_url }); │ │803 const wrong_repo_rejected = if (client.push(io, allocator, "other", "master:patch", false, .{ .wire = .{ .ssh = .{ .command = ssh_cmd } } })) |_| false else |_| true;│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │854 }); │ │855 } │ │856 │ │864 - const denied_url = try std.fmt.allocPrint(allocator, "git@localhost:fork/admin/target/patch:{s}/branch:denied", .{&fork_id_hex}); │ │857 + const denied_url = try std.fmt.allocPrint(allocator, "git@localhost:fork/admin/target/patch:{s}", .{&fork_id_hex}); │ │858 defer allocator.free(denied_url); │ │859 try client.addRemote(io, allocator, .{ .name = "denied", .value = denied_url }); │ │860 const unauthorized_rejected = if (client.push(io, allocator, "denied", "master:patch", false, .{ .wire = .{ .ssh = .{ .command = ssh_cmd } } })) |_| false else |_| true;│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──╮ │src/try.zig│ ╰───────────╯ ╭───────────────────────────────────────────────────╮ │1040 const revision: evt.PatchRev = .{ │ │1041 .base_oid = &base_oid, │ │1042 .source_oid = &source_oid, │ │1043 - .target_ref = "refs/heads/master", │ │1043 .message = title, │ │1044 }; │ │1045 const revision_timestamp = timestamp + 3;│ ╰───────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────╮ │1133 .title = patch.title, │ │1134 .description = patch.description,│ │1135 .tags = patch.tags, │ │1136 + .target_branch = "master", │ │1137 .author = patch_author, │ │1138 .timestamp = timestamp, │ │1139 }); │ ╰───────────────────────────────────────────────────╯ ╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │390 fork: struct { │ │391 identity: []const u8, │ │392 id: []const u8, │ │393 - target_branch: []const u8, │ │393 }, │ │394 │ │395 pub fn dupe(self: RepoLocation, allocator: std.mem.Allocator) !RepoLocation {│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │398 .fork => |f| .{ .fork = .{ │ │399 .identity = try allocator.dupe(u8, f.identity), │ │400 .id = try allocator.dupe(u8, f.id), │ │402 - .target_branch = try allocator.dupe(u8, f.target_branch),│ │401 } }, │ │402 }; │ │403 } │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1586 pub fn localInitOpts(self: RepoSource) rp.InitOpts { │ │1587 return .{ .path = self.path, .global_config_path = self.global_config_path }; │ │1588 } │ │1589 + │ │1590 + pub fn hasBranch(self: RepoSource, io: std.Io, allocator: std.mem.Allocator, branch: []const u8) !bool { │ │1591 + if (!xit.ref.validateName(branch)) return false; │ │1592 + return switch (self.repo_kind) { │ │1593 + inline else => |repo_kind| blk: { │ │1594 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, self.localInitOpts()); │ │1595 + defer any_repo.deinit(io, allocator); │ │1596 + break :blk switch (any_repo) { │ │1597 + inline else => |*repo| (try repo.readRef(io, .{ .kind = .head, .name = branch })) != null,│ │1598 + }; │ │1599 + }, │ │1600 + }; │ │1601 + } │ │1602 }; │ │1603 │ │1604 // events created in local mode have no account behind them, so the commit │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯