gitea icon indicating copy to clipboard operation
gitea copied to clipboard

Add a way to opt out of repo code indexing, on a per-repo basis

Open algernon opened this issue 3 years ago • 3 comments

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

Screenshot from 2022-07-23 06-49-43

algernon avatar Jul 20 '22 00:07 algernon

Codecov Report

Merging #20418 (4c9b50e) into main (fee0e4d) will increase coverage by 0.00%. The diff coverage is 14.51%.

@@           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           
Impacted Files Coverage Δ
cmd/admin.go 0.00% <0.00%> (ø)
models/issues/review.go 52.77% <0.00%> (-1.31%) :arrow_down:
models/repo/repo.go 62.61% <ø> (ø)
routers/web/org/members.go 0.00% <0.00%> (ø)
routers/web/repo/pull_review.go 0.00% <0.00%> (ø)
routers/web/repo/setting.go 16.61% <0.00%> (-0.31%) :arrow_down:
services/forms/repo_form.go 40.76% <ø> (ø)
services/pull/review.go 48.24% <7.14%> (-2.58%) :arrow_down:
modules/indexer/code/indexer.go 32.15% <100.00%> (+0.90%) :arrow_up:
modules/repository/create.go 43.35% <100.00%> (+0.32%) :arrow_up:
... and 9 more

codecov-commenter avatar Jul 20 '22 00:07 codecov-commenter

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, code.UpdateRepoIndexer() is triggered. That's something another option hidden behind an admin-only flag does too, so perhaps it would make more sense to not call it here, and just have the next indexer run - whenever it happens - take care of updating things. However, that has the downside of the change potentially taking a long time to take effect.

algernon avatar Jul 23 '22 04:07 algernon

I would say that changing option should trigger repository reindex as it may not happen ever if repository is not changed

lafriks avatar Jul 23 '22 15:07 lafriks