-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to opt out of repo code indexing, on a per-repo basis #20418
Conversation
Codecov Report
@@ Coverage Diff @@
## main #20418 +/- ##
=======================================
Coverage 46.88% 46.88%
=======================================
Files 976 976
Lines 135193 135248 +55
=======================================
+ Hits 63384 63413 +29
- Misses 64040 64066 +26
Partials 7769 7769
|
Add a repository setting to opt out of code indexing. When the indexer iterates over repositories, if it sees a repo with the setting disabled, it will remove that repository from the index, otherwise it continues. The new setting is on by default, and is exposed in the repository settings page, in the advanced settings box, right alongside the Projects and Packages enabling checkboxes. Addresses #17824, albeit in a different way. Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
I turned the setting into something accessible for all repo owners, rather than limiting it to admins. The only part I'm unsure about is where toggling the option on or off and updating the settings, |
I would say that changing option should trigger repository reindex as it may not happen ever if repository is not changed |
@@ -158,6 +158,7 @@ type Repository struct { | |||
CodeIndexerStatus *RepoIndexerStatus `xorm:"-"` | |||
StatsIndexerStatus *RepoIndexerStatus `xorm:"-"` | |||
IsFsckEnabled bool `xorm:"NOT NULL DEFAULT true"` | |||
IsCodeIndexingEnabled bool `xorm:"NOT NULL DEFAULT true"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This require a migration, it should be similar to models/migrations/v219.go
, copy paste this whole struct(fixup the imports) and run Sync2 on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
May take a day or two until I have some cycles to spend on updating this PR, but I'll get there eventually.
<input class="enable-system" name="enable_code_indexing" type="checkbox" {{if .Repository.IsCodeIndexingEnabled}}checked{{end}}> | ||
<label>{{.locale.Tr "repo.settings.code_search_indexing_desc"}}</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<input class="enable-system" name="enable_code_indexing" type="checkbox" {{if .Repository.IsCodeIndexingEnabled}}checked{{end}}> | |
<label>{{.locale.Tr "repo.settings.code_search_indexing_desc"}}</label> | |
<input type="checkbox" class="enable-system" id="code-indexing-checkbox" name="enable_code_indexing"{{if .Repository.IsCodeIndexingEnabled}} checked{{end}}> | |
<label for="code-indexing-checkbox">{{.locale.Tr "repo.settings.code_search_indexing_desc"}}</label> |
if repo.IsCodeIndexingEnabled != form.EnableCodeIndexing { | ||
repo.IsCodeIndexingEnabled = form.EnableCodeIndexing | ||
codeIndexingChanged = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if repo.IsCodeIndexingEnabled != form.EnableCodeIndexing { | |
repo.IsCodeIndexingEnabled = form.EnableCodeIndexing | |
codeIndexingChanged = true | |
} | |
codeIndexingChanged = repo.IsCodeIndexingEnabled != form.EnableCodeIndexing | |
if codeIndexingChanged { | |
repo.IsCodeIndexingEnabled = form.EnableCodeIndexing | |
} |
Add a repository setting to opt out of code indexing. When the indexer iterates over repositories, if it sees a repo with the setting disabled, it will remove that repository from the index, otherwise it continues.
The new setting is on by default, and is exposed in the repository settings page, in the advanced settings box, right alongside the Projects and Packages enabling checkboxes.
Addresses #17824, albeit in a different way.
Screenshot