╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
154 owner_name: []const u8, 155 repo_name: []const u8, 156 ) !?RepoWithId { 157 // owner name -> user id 158 const name_to_user_id_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "name->user-id")) orelse return null; 159 const name_to_user_id = try DB.HashMap(.read_only).init(name_to_user_id_cursor); 160 const user_id_cursor = try name_to_user_id.getCursor(hash.hashInt(hash_kind, owner_name)) orelse return null; 161 var user_id: [evt.event_id_size]u8 = undefined; 162 _ = try user_id_cursor.readBytes(&user_id); 163 164 // "user-id/repo-name" -> repo event id 165 const repo_path = try std.fmt.allocPrint(arena.allocator(), "{s}/{s}", .{ user_id[0..], repo_name }); 166 const name_to_repo_id_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "name->repo-id")) orelse return null; 167 const name_to_repo_id = try DB.HashMap(.read_only).init(name_to_repo_id_cursor); 168 const repo_id_cursor = try name_to_repo_id.getCursor(hash.hashInt(hash_kind, repo_path)) orelse return null; 169 var repo_id: [evt.event_id_size]u8 = undefined; 170 _ = try repo_id_cursor.readBytes(&repo_id); 171 172 const event_id_to_repo_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "event-id->repo")) orelse return null; 173 const event_id_to_repo = try DB.HashMap(.read_only).init(event_id_to_repo_cursor); 174 const repo_cursor = try event_id_to_repo.getCursor(hash.hashInt(hash_kind, &repo_id)) orelse return null; 175 const repo_map = try DB.HashMap(.read_only).init(repo_cursor); 176 return .{ .repo = try evt.read(@This(), DB, hash_kind, arena, repo_map), .event_id = repo_id }; 177 } 178