╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ patch.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
781 try std.testing.expectEqualStrings(&selected_oid, merged_oid); 782 try std.testing.expect(null != try evt.PatchRev.readById(Repo.DB, repo_opts.hash, merged_moment, &arena, &first_patchrev_id)); 783 784 _ = arena.reset(.retain_capacity); 785 const removed_fork = (try evt.Fork.readById(evt.AdminDB, evt.admin_repo_opts.hash, try evt.currentMoment(evt.admin_repo_opts, &admin), &arena, &patch_id)) orelse return error.NotFound; 786 try std.testing.expect(removed_fork.removed); 787 } 788 789 fn indexedForkCount( 790 moment: evt.AdminDB.HashMap(.read_only), 791 index_key: []const u8, 792 parent_id: []const u8, 793 ) !u64 { 794 const index_cursor = try moment.getCursor(hash.hashInt(evt.admin_repo_opts.hash, index_key)) orelse return 0; 795 const index = try evt.AdminDB.HashMap(.read_only).init(index_cursor); 796 const ids_cursor = try index.getCursor(hash.hashInt(evt.admin_repo_opts.hash, parent_id)) orelse return 0; 797 const ids = try evt.AdminDB.SortedSet(.read_only).init(ids_cursor); 798 return try ids.count(); 799 } 800 801 fn patchStatusCount(moment: Repo.DB.HashMap(.read_only), status: evt.Patch.StatusKind) !u64 { 802 const statuses_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, evt.Patch.status_to_id_set_key)) orelse return 0; 803 const statuses = try Repo.DB.SortedMap(.read_only).init(statuses_cursor); 804 const ids_cursor = try statuses.getCursor(@tagName(status)) orelse return 0; 805 const ids = try Repo.DB.SortedSet(.read_only).init(ids_cursor); 806 return try ids.count(); 807 } 808 809 fn patchTagStatusCount(moment: Repo.DB.HashMap(.read_only), tag: []const u8, status: evt.Patch.StatusKind) !u64 { 810 const tags_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, evt.Patch.tag_status_to_id_set_key)) orelse return 0; 811 const tags = try Repo.DB.SortedMap(.read_only).init(tags_cursor); 812 var key_buffer: evt.Patch.TagStatusKey = undefined; 813 const ids_cursor = try tags.getCursor(try evt.Patch.tagStatusKey(&key_buffer, tag, status)) orelse return 0; 814 const ids = try Repo.DB.SortedSet(.read_only).init(ids_cursor); 815 return try ids.count(); 816 } 817