╭ changed ──────────╮ │src/event/Issue.zig│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │ 8 │ │ 9 title: []const u8, │ │10 description: []const u8, │ │11 -tags: []const u8, // space-separated │ │11 +labels: []const u8, // space-separated │ │12 status: Status = .open, │ │13 │ │14 // what the db stores: the event's data plus the commit-derived fields│ ╰──────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────╮ │33 }; │ │34 }; │ │35 │ │36 -pub const tag_max_len = 64; │ │36 +pub const label_max_len = 64; │ │37 │ │38 // the moment keys `evt.merge` reads and writes for this kind│ │39 pub const merge_policy: evt.MergePolicy = .field_conflicts; │ ╰─────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │42 pub const conflicts_key = "conflicted-issue-id->conflict"; │ │43 pub const id_to_field_to_oid_key = "issue-id->field->oid"; │ │44 pub const status_to_id_set_key = "status->issue-id-set"; │ │45 -pub const tag_status_to_id_set_key = "tag+status->issue-id-set"; │ │45 +pub const label_status_to_id_set_key = "label+status->issue-id-set"; │ │46 │ │47 -// a "tag status" key names a tag's per-status issue set (tags can't contain │ │47 +// a "label status" key names a label's per-status issue set (labels can't contain │ │48 // spaces, so the pair is unambiguous) │ │49 -pub const TagStatusKey = [tag_max_len + 1 + Status.longest_len]u8; │ │49 +pub const LabelStatusKey = [label_max_len + 1 + Status.longest_len]u8; │ │50 │ │51 -pub fn tagStatusKey(buffer: *TagStatusKey, tag: []const u8, status: Status) ![]const u8 { │ │52 - return std.fmt.bufPrint(buffer, "{s} {s}", .{ tag, @tagName(status) }); │ │51 +pub fn labelStatusKey(buffer: *LabelStatusKey, label: []const u8, status: Status) ![]const u8 {│ │52 + return std.fmt.bufPrint(buffer, "{s} {s}", .{ label, @tagName(status) }); │ │53 } │ │54 │ │55 -pub fn tagIterator(tags: []const u8) std.mem.SplitIterator(u8, .scalar) { │ │56 - return std.mem.splitScalar(u8, tags, ' '); │ │55 +pub fn labelIterator(labels: []const u8) std.mem.SplitIterator(u8, .scalar) { │ │56 + return std.mem.splitScalar(u8, labels, ' '); │ │57 } │ │58 │ │59 -// a title is required, and a too-long tag would go unindexed once consumed │ │60 -pub fn fieldsValid(title: []const u8, tags: []const u8) bool { │ │59 +// a title is required, and a too-long label would go unindexed once consumed │ │60 +pub fn fieldsValid(title: []const u8, labels: []const u8) bool { │ │61 if (!evt.titleValid(title)) return false; │ │62 - var tag_iter = tagIterator(tags); │ │63 - while (tag_iter.next()) |tag| { │ │64 - if (tag.len > tag_max_len) return false; │ │62 + var label_iter = labelIterator(labels); │ │63 + while (label_iter.next()) |label| { │ │64 + if (label.len > label_max_len) return false; │ │65 } │ │66 return true; │ │67 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │87 const status_to_issues_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, status_to_id_set_key)); │ │88 const status_to_issues = try DB.SortedMap(.read_write).init(status_to_issues_cursor); │ │89 │ │90 - // the per-tag, per-status sets, keyed "tag,status" │ │91 - const tag_to_issues_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, tag_status_to_id_set_key)); │ │92 - const tag_to_issues = try DB.SortedMap(.read_write).init(tag_to_issues_cursor); │ │90 + // the per-label, per-status sets, keyed "label,status" │ │91 + const label_to_issues_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, label_status_to_id_set_key));│ │92 + const label_to_issues = try DB.SortedMap(.read_write).init(label_to_issues_cursor); │ │93 │ │94 const conflicts_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, conflicts_key)); │ │95 const conflicts = try DB.SortedMap(.read_write).init(conflicts_cursor); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │111 record_to_write.created_order = existing_record.created_order; │ │112 record_to_write.author_email = existing_record.author_email; │ │113 │ │114 - // drop the old status's and tags' entries; active values are re-added below │ │114 + // drop the old status's and labels' entries; active values are re-added below │ │115 const order_key = evt.orderKeyDesc(existing_record.created_order, event_id); │ │116 if (!existing_record.removed) { │ │117 const status_set = try statusSet(DB, status_to_issues, existing_record.event.status);│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │118 _ = try status_set.remove(&order_key); │ │119 - try removeFromTagSets(DB, tag_to_issues, existing_record.event.tags, existing_record.event.status, &order_key); │ │119 + try removeFromLabelSets(DB, label_to_issues, existing_record.event.labels, existing_record.event.status, &order_key);│ │120 } │ │121 │ │122 // any event settles the conflict, since resolving in the ui may │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │147 const status_set = try statusSet(DB, status_to_issues, record_to_write.event.status); │ │148 try status_set.put(&order_key); │ │149 │ │150 - var tag_iter = tagIterator(record_to_write.event.tags); │ │151 - while (tag_iter.next()) |tag| { │ │152 - // an over-long tag goes unindexed rather than failing the consume, │ │150 + var label_iter = labelIterator(record_to_write.event.labels); │ │151 + while (label_iter.next()) |label| { │ │152 + // an over-long label goes unindexed rather than failing the consume, │ │153 // which would wedge the branch it arrived on │ │154 - if (tag.len == 0 or tag.len > tag_max_len) continue; │ │155 - var key_buffer: TagStatusKey = undefined; │ │156 - const tag_set_cursor = try tag_to_issues.putCursor(try tagStatusKey(&key_buffer, tag, record_to_write.event.status)); │ │157 - const tag_set = try DB.SortedSet(.read_write).init(tag_set_cursor); │ │158 - try tag_set.put(&order_key); │ │154 + if (label.len == 0 or label.len > label_max_len) continue; │ │155 + var key_buffer: LabelStatusKey = undefined; │ │156 + const label_set_cursor = try label_to_issues.putCursor(try labelStatusKey(&key_buffer, label, record_to_write.event.status));│ │157 + const label_set = try DB.SortedSet(.read_write).init(label_set_cursor); │ │158 + try label_set.put(&order_key); │ │159 } │ │160 } │ │161 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────╮ │175 // trailing ones keep our side) │ │176 pub const Resolve = struct { │ │177 title: ?[]const u8 = null, │ │178 - tags: ?[]const u8 = null, │ │178 + labels: ?[]const u8 = null, │ │179 hunks: []const []const u8 = &.{},│ │180 }; │ │181 │ ╰──────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │183 // conflicted issue — the resolution of its conflict │ │184 pub const Update = union(enum) { │ │185 status: Status, │ │186 - fields: struct { title: []const u8, tags: []const u8, description: []const u8 }, │ │186 + fields: struct { title: []const u8, labels: []const u8, description: []const u8 },│ │187 resolve: Resolve, │ │188 }; │ │189 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────╮ │216 }, │ │217 .fields => |fields| { │ │218 updated.title = fields.title; │ │219 - updated.tags = fields.tags; │ │219 + updated.labels = fields.labels; │ │220 updated.description = fields.description;│ │221 }, │ │222 .resolve => |resolve| { │ ╰──────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯