╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issue.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
303 hunk_index += 1; 304 } 305 updated.description = try diff3.assemble(aa, chunks, resolutions.items); 306 return updated; 307 } 308 309 // the issue `id_bytes` names in the repo's consumed event db (the repo's own 310 // db for xit; the side db next to a git repo), or null 311 fn readById( 312 comptime repo_kind: rp.RepoKind, 313 comptime repo_opts: rp.RepoOpts(repo_kind), 314 io: std.Io, 315 allocator: std.mem.Allocator, 316 arena: *std.heap.ArenaAllocator, 317 repo: *rp.Repo(repo_kind, repo_opts), 318 id_bytes: *const [evt.event_id_size]u8, 319 ) !?Record { 320 const DB = evt.EventDB(repo_opts.hash); 321 var event_db_maybe: ?evt.LocalEventDB(repo_opts.hash) = if (repo_kind == .git) try evt.LocalEventDB(repo_opts.hash).openReadOnly(io, allocator, repo.core.repo_dir) else null; 322 defer if (event_db_maybe) |*event_db| event_db.deinit(io, allocator); 323 const moment = (if (event_db_maybe) |*event_db| 324 evt.currentMomentFromDb(repo_opts.hash, event_db.db) 325 else if (repo_kind == .git) 326 return null 327 else 328 evt.currentMoment(repo_opts, repo)) catch return null; 329 const event_id_to_issue_cursor = (try moment.getCursor(hash.hashInt(repo_opts.hash, record_map_key))) orelse return null; 330 const event_id_to_issue = try DB.HashMap(.read_only).init(event_id_to_issue_cursor); 331 const issue_cursor = (try event_id_to_issue.getCursor(hash.hashInt(repo_opts.hash, id_bytes))) orelse return null; 332 const issue_map = try DB.HashMap(.read_only).init(issue_cursor); 333 return try evt.read(Record, DB, repo_opts.hash, arena, issue_map); 334 } 335 336 // remove an issue's order key from its labels' `status` sets, pruning entries 337 // whose set becomes empty 338 fn removeFromLabelSets( 339 comptime DB: type, 340 label_to_issues: DB.SortedMap(.read_write), 341 labels: []const u8, 342 status: Status, 343 order_key: []const u8, 344 ) !void { 345 var label_iter = labelIterator(labels); 346 while (label_iter.next()) |label| { 347 // skipped the same way consume skipped it, so it was never indexed 348 if (label.len == 0 or label.len > label_max_len) continue; 349 var key_buffer: LabelStatusKey = undefined; 350 const key = try labelStatusKey(&key_buffer, label, status); 351 const label_set_cursor = try label_to_issues.putCursor(key); 352 const label_set = try DB.SortedSet(.read_write).init(label_set_cursor); 353 _ = try label_set.remove(order_key); 354 if (0 == try label_set.count()) _ = try label_to_issues.remove(key); 355 } 356 } 357