Allow skipping forks and mirrors from being indexed (#23187)
This PR adds two new options to disable repo/code search indexing of both forks and mirrors. Related: #22842
This commit is contained in:
parent
cff4e37d43
commit
033d92997f
4 changed files with 51 additions and 16 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/queue"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
// SearchResult result of performing a search in a repo
|
||||
|
@ -91,6 +92,32 @@ func index(ctx context.Context, indexer Indexer, repoID int64) error {
|
|||
return err
|
||||
}
|
||||
|
||||
repoTypes := setting.Indexer.RepoIndexerRepoTypes
|
||||
|
||||
if len(repoTypes) == 0 {
|
||||
repoTypes = []string{"sources"}
|
||||
}
|
||||
|
||||
// skip forks from being indexed if unit is not present
|
||||
if !util.SliceContains(repoTypes, "forks") && repo.IsFork {
|
||||
return nil
|
||||
}
|
||||
|
||||
// skip mirrors from being indexed if unit is not present
|
||||
if !util.SliceContains(repoTypes, "mirrors") && repo.IsMirror {
|
||||
return nil
|
||||
}
|
||||
|
||||
// skip templates from being indexed if unit is not present
|
||||
if !util.SliceContains(repoTypes, "templates") && repo.IsTemplate {
|
||||
return nil
|
||||
}
|
||||
|
||||
// skip regular repos from being indexed if unit is not present
|
||||
if !util.SliceContains(repoTypes, "sources") && !repo.IsFork && !repo.IsMirror && !repo.IsTemplate {
|
||||
return nil
|
||||
}
|
||||
|
||||
sha, err := getDefaultBranchSha(ctx, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue