╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
271 try events.append(allocator, .{ 272 .parent_oid = commit.parent_oid, 273 .oid = commit.oid, 274 .event = event, 275 }); 276 } 277 } 278 279 // 280 // consume events into the database 281 // 282 283 { 284 try evt.consume(Repo.DB, repo_opts.hash, io, &repo.core.db, repo.core.db_file, events.items); 285 286 const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); 287 288 // read the moment we just created 289 const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; 290 const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); 291 292 const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; 293 const haxy = try Repo.DB.HashMap(.read_only).init(haxy_cursor); 294 295 const object_id_to_views_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "object-id->views")) orelse return error.NotFound; 296 const object_id_to_views = try Repo.DB.HashMap(.read_only).init(object_id_to_views_cursor); 297 298 // get the last object id 299 const last_object_id_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "last-object-id")) orelse return error.NotFound; 300 var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; 301 _ = try last_object_id_cursor.readBytes(&last_object_id); 302 303 // get the latest views (the views generated by the last object id) 304 const views_cursor = try object_id_to_views.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; 305 const views = try Repo.DB.HashMap(.read_only).init(views_cursor); 306 307 // get the map of issues 308 const event_id_to_issue_cursor = try views.getCursor(hash.hashInt(repo_opts.hash, "event-id->issue")) orelse return error.NotFound; 309 const event_id_to_issue = try Repo.DB.HashMap(.read_only).init(event_id_to_issue_cursor); 310 311 // get the issue out of the map that was edited 312 const first_issue_cursor = try event_id_to_issue.getCursor(hash.hashInt(repo_opts.hash, &first_event_id)) orelse return error.NotFound; 313 const first_issue_map = try Repo.DB.HashMap(.read_only).init(first_issue_cursor); 314 const first_issue = try evt.EventData.read(Repo.DB, repo_opts.hash, arena.allocator(), first_issue_map, .issue); 315 316 // the description is no longer edited 317 try std.testing.expectEqualStrings(events_to_consume[0].data.issue.description, first_issue.issue.description); 318 319 // the tags are no longer edited 320 try std.testing.expectEqualStrings(events_to_consume[0].data.issue.tags, first_issue.issue.tags); 321 } 322 } 323