Skip to content

index: match listed repositories by ID when available - #1296

Merged
keegancsmith merged 2 commits into
sourcegraph:mainfrom
perfloop-oss:perfloop-pr-open-qtxj9f0fk8
Nov 26, 2026
Merged

keegancsmith merged 2 commits into
sourcegraph:mainfrom
perfloop-oss:perfloop-pr-open-qtxj9f0fk8

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

Listing repositories in a compound shard can include repositories that do not match the query when they share a name with a matching repository. Those extra repositories also inflate the aggregate statistics. With IDs 0, 1 and 2 all named same-name, for example, an ID-1 query previously listed all three repositories; it now lists only ID 1.

cc @camdencheek @keegancsmith

indexData.List now records nonzero repository IDs from the bounded search and checks those IDs when selecting entries. Matches from repositories without an ID go into a separate name set, so the legacy path cannot select a same-named repository with a nonzero ID, or vice versa. The existing entries still supply metadata, branches and statistics in both output formats. Tenant access checks and tombstone filtering are unchanged.

The tests in index/index_test.go cover same-named repositories with mixed zero/nonzero IDs, query-specific selection and complete statistics in both formats. The existing content-listing test also covers distinct names with unset IDs while retaining its simple-shard case.

Go tests for index listing, sharded listing and type:repo query evaluation passed.

Repositories without IDs still use name-based matching.

go test ./... passes locally with the change based on 7b032f67 and on b55ce727.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks

@keegancsmith
keegancsmith merged commit 6c9bee4 into sourcegraph:main Nov 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants