Repository navigation
query: filter repositories by topic - #1305
Open
Indian-boult wants to merge 2 commits into
Open
Indian-boult wants to merge 2 commits into
Indian-boult wants to merge 2 commits into
Conversation
MergeMutable copies the RawConfig keys of the new description into the indexed one, but it never removes a key the new description no longer has. So when a zoekt.* git config key is unset and no commit changed, IndexState reports the index as equal and the old value stays in the shard until the next content change. Now a RawConfig key missing from the new description is removed and counts as a change. name and id are still skipped, since the Sourcegraph indexserver writes zoekt.name to git config but leaves it out of the RawConfig it compares against. Signed-off-by: Indian-boult <64060864+Indian-boult@users.noreply.github.com>
`topic:go` matches the repositories that have go among their topics. The whole topic has to match, ignoring case, and it works with negation and or like the other repository filters. Topics are the comma-separated `zoekt.topics` git config, which zoekt-git-index already copies into RawConfig like `zoekt.archived`. So updating them only rewrites the shard metadata and does not change the index format. zoekt-mirror-github and zoekt-mirror-gitlab now set the key from the topics the code host lists for each repository, and unset it when a repository has none. The filter is evaluated per repository in the match tree, simplified to true or false for a shard where all or no repositories match, and used to skip shards without a matching repository, the same way `meta.<field>:` is. The query is also added to the gRPC query proto. Signed-off-by: Indian-boult <64060864+Indian-boult@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the
topic:filter from #783.topic:go needlesearches only the repositories that have go among their topics. The whole topic has to match, ignoring case, since GitHub stores topics in lowercase while GitLab keeps the case they were typed with. It works with-andorlike the other repository filters, andtype:repo topic:golists the repositories.Topics are the comma-separated
zoekt.topicsgit config. zoekt-git-index already copies everyzoekt.*key into RawConfig, wherearchived:,fork:andpublic:read from, so updating topics only rewrites the shard metadata and the index format doesn't change. zoekt-mirror-github and zoekt-mirror-gitlab now set the key from the topics in their repository list responses and unset it when a repository has none. Anyone indexing with their own tooling can set it withgit config zoekt.topics go,search.The filter is handled like
meta.<field>:. The match tree checks it once per repository,simplifyturns it into true or false when all or none of a shard's repositories match, anddoSelectRepoSetuses it to skip shards and drops it from the query when every remaining repository matches. The query proto gets aTopicmessage, generated with buf.The first commit fixes something this depends on.
MergeMutablenever removed a RawConfig key, so when a repository lost its last topic and the mirror unsetzoekt.topics, an incremental zoekt-git-index run found the index equal and kept the old topics until the next commit. It now removes keys that are missing from the new description, and still skips name and id. The Sourcegraph indexserver writes the same RawConfig keys on every run pluszoekt.name, which is skipped, so its shards compare the same as before.zoekt-mirror-gitea is unchanged because the Gitea SDK version we use has no topics in its repository struct, so it would need an extra request per repository. Showing topics in the web UI could come later too.
TestIndexGitRepo_IncrementalTopicsConfigfails on main at the unset step withupdated=falseand the old topics still in the shard. New tests cover parsing, the proto round trip, Search and List on simple and compound shards, simplify and shard selection.go test ./...passes apart fromTestLoggedRunFailure, which fails on main here too, and-racepasses on the root, query, index, search and gitindex packages. buf lint, format and breaking pass, and buf generate on main reproduces the checked in code.Closes #783