╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
187 role: ?Role, 188 }; 189 190 // read a repo by its name from its owner's user repo 191 pub fn readByName( 192 comptime DB: type, 193 comptime hash_kind: hash.HashKind, 194 user_moment: DB.HashMap(.read_only), 195 arena: *std.heap.ArenaAllocator, 196 name: []const u8, 197 ) !?RepoWithId { 198 const name_to_repo_id_cursor = try user_moment.getCursor(hash.hashInt(hash_kind, name_index_key)) orelse return null; 199 const name_to_repo_id = try DB.SortedMap(.read_only).init(name_to_repo_id_cursor); 200 const repo_id_cursor = try name_to_repo_id.getCursor(name) orelse return null; 201 var repo_id: [evt.event_id_size]u8 = undefined; 202 _ = try repo_id_cursor.readBytes(&repo_id); 203 const repo = (try readById(DB, hash_kind, user_moment, arena, &repo_id)) orelse return null; 204 return .{ .repo = repo, .event_id = repo_id }; 205 } 206 207 // a deleted repo reads as missing 208 pub fn readById( 209 comptime DB: type, 210 comptime hash_kind: hash.HashKind, 211 haxy_moment: DB.HashMap(.read_only), 212 arena: *std.heap.ArenaAllocator, 213 id: []const u8, 214 ) !?Record { 215 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 216 const records = try DB.HashMap(.read_only).init(records_cursor); 217 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, id)) orelse return null; 218 const record = try evt.read(Record, DB, hash_kind, arena, try DB.HashMap(.read_only).init(record_cursor)); 219 return if (record.removed) null else record; 220 } 221