╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────────╮ │src/event/Patch.zig│ ╰───────────────────╯ ╭─────────────────────────────────────────╮ │79 │ │80 pub const Resolve = struct { │ │81 title: ?[]const u8 = null, │ │82 - tags: ?[]const u8 = null, │ │82 + labels: ?[]const u8 = null, │ │83 hunks: []const []const u8 = &.{},│ │84 theirs: []const u8 = "", │ │85 }; │ ╰─────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │86 │ │87 pub const Update = union(enum) { │ │88 status: StatusKind, │ │89 - fields: struct { title: []const u8, tags: []const u8, description: []const u8, target_branch: []const u8 }, │ │89 + fields: struct { title: []const u8, labels: []const u8, description: []const u8, target_branch: []const u8 },│ │90 resolve: Resolve, │ │91 }; │ │92 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────╮ │93 -pub const tag_max_len = 64; │ │93 +pub const label_max_len = 64; │ │94 pub const merge_policy: evt.MergePolicy = .field_conflicts;│ │95 pub const record_map_key = "event-id->patch"; │ │96 pub const all_id_set_key = "patch-id-set"; │ ╰───────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │ 98 pub const id_to_field_to_oid_key = "patch-id->field->oid"; │ │ 99 pub const target_patch_id_to_patch_id_set_key = "target-patch-id->patch-id-set";│ │100 pub const status_to_id_set_key = "status->patch-id-set"; │ │101 -pub const tag_status_to_id_set_key = "tag+status->patch-id-set"; │ │101 +pub const label_status_to_id_set_key = "label+status->patch-id-set"; │ │102 pub const revision_to_id_set_key = "target-branch+oid->patch-id-set"; │ │103 pub const source_to_id_set_key = "source-branch->patch-id-set"; │ │104 pub const patch_id_to_mergeability_key = "patch-id->mergeability"; │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │105 │ │106 -pub const TagStatusKey = [tag_max_len + 1 + StatusKind.longest_len]u8; │ │106 +pub const LabelStatusKey = [label_max_len + 1 + StatusKind.longest_len]u8; │ │107 │ │108 -pub fn tagStatusKey(buffer: *TagStatusKey, tag: []const u8, status: StatusKind) ![]const u8 { │ │109 - return std.fmt.bufPrint(buffer, "{s} {s}", .{ tag, @tagName(status) }); │ │108 +pub fn labelStatusKey(buffer: *LabelStatusKey, label: []const u8, status: StatusKind) ![]const u8 {│ │109 + return std.fmt.bufPrint(buffer, "{s} {s}", .{ label, @tagName(status) }); │ │110 } │ │111 │ │112 -pub fn tagIterator(tags: []const u8) std.mem.SplitIterator(u8, .scalar) { │ │113 - return std.mem.splitScalar(u8, tags, ' '); │ │112 +pub fn labelIterator(labels: []const u8) std.mem.SplitIterator(u8, .scalar) { │ │113 + return std.mem.splitScalar(u8, labels, ' '); │ │114 } │ │115 │ │116 -pub fn fieldsValid(title: []const u8, tags: []const u8) bool { │ │116 +pub fn fieldsValid(title: []const u8, labels: []const u8) bool { │ │117 if (!evt.titleValid(title)) return false; │ │118 - var tag_iter = tagIterator(tags); │ │119 - while (tag_iter.next()) |tag| { │ │120 - if (tag.len > tag_max_len) return false; │ │118 + var label_iter = labelIterator(labels); │ │119 + while (label_iter.next()) |label| { │ │120 + if (label.len > label_max_len) return false; │ │121 } │ │122 return true; │ │123 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │138 const record_key = hash.hashInt(hash_kind, event_id); │ │139 const records = try DB.HashMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, record_map_key))); │ │140 const statuses = try DB.SortedMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, status_to_id_set_key))); │ │141 - const tag_statuses = try DB.SortedMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, tag_status_to_id_set_key))); │ │141 + const label_statuses = try DB.SortedMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, label_status_to_id_set_key)));│ │142 const conflicts = try DB.SortedMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, conflicts_key))); │ │143 const field_oid_map = try DB.HashMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, id_to_field_to_oid_key))); │ │144 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │150 │ │151 var record = record_maybe orelse try evt.removedRecord(Record, DB, hash_kind, haxy_moment.readOnly(), existing_maybe);│ │152 │ │153 - if (!fieldsValid(record.event.title, record.event.tags)) return error.InvalidPatch; │ │153 + if (!fieldsValid(record.event.title, record.event.labels)) return error.InvalidPatch; │ │154 if (!branchValid(record.event.target_branch)) return error.InvalidTargetBranch; │ │155 if (record.event.source_branch) |branch| { │ │156 if (!branchValid(branch)) return error.InvalidSourceBranch; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │209 const existing_status_kind = existing.event.status.kind(); │ │210 const old_status = try statusSet(DB, statuses, existing_status_kind); │ │211 _ = try old_status.remove(&order_key); │ │212 - try removeFromTagSets(DB, tag_statuses, existing.event.tags, existing_status_kind, &order_key); │ │212 + try removeFromLabelSets(DB, label_statuses, existing.event.labels, existing_status_kind, &order_key); │ │213 if (existing_status_kind != .merged) { │ │214 if (existing.event.revision) |revision| { │ │215 const revisions = try DB.HashMap(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, revision_to_id_set_key)));│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │260 const status = try statusSet(DB, statuses, status_kind); │ │261 try status.put(&order_key); │ │262 │ │263 - var tag_iter = tagIterator(record.event.tags); │ │264 - while (tag_iter.next()) |tag| { │ │265 - if (tag.len == 0 or tag.len > tag_max_len) continue; │ │266 - var key_buffer: TagStatusKey = undefined; │ │267 - const set = try DB.SortedSet(.read_write).init(try tag_statuses.putCursor(try tagStatusKey(&key_buffer, tag, status_kind))); │ │263 + var label_iter = labelIterator(record.event.labels); │ │264 + while (label_iter.next()) |label| { │ │265 + if (label.len == 0 or label.len > label_max_len) continue; │ │266 + var key_buffer: LabelStatusKey = undefined; │ │267 + const set = try DB.SortedSet(.read_write).init(try label_statuses.putCursor(try labelStatusKey(&key_buffer, label, status_kind)));│ │268 try set.put(&order_key); │ │269 } │ │270 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │333 if (!branchValid(fields.target_branch)) return error.InvalidTargetBranch; │ │334 if ((try repo.readRef(io, .{ .kind = .head, .name = fields.target_branch })) == null) return error.InvalidTargetBranch;│ │335 updated.title = fields.title; │ │336 - updated.tags = fields.tags; │ │336 + updated.labels = fields.labels; │ │337 updated.description = fields.description; │ │338 if (!std.mem.eql(u8, updated.target_branch, fields.target_branch)) updated.revision = null; │ │339 updated.target_branch = fields.target_branch; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯