summaryrefslogtreecommitdiffstats
path: root/modules/indexer
diff options
context:
space:
mode:
authorNanguan Lin <70063547+lng2020@users.noreply.github.com>2023-09-13 12:43:31 +0800
committerGitHub <noreply@github.com>2023-09-13 04:43:31 +0000
commitcda97a725347cdadd43af812749732b9d1ee6429 (patch)
tree133cde4ac79c539803e2262faff2c6e1ad0659fd /modules/indexer
parente6a059a3d0c699e00c05cfa81ab3bfd0598a89a2 (diff)
downloadgitea-cda97a725347cdadd43af812749732b9d1ee6429.tar.gz
gitea-cda97a725347cdadd43af812749732b9d1ee6429.zip
Update status and code index after changing the default branch (#27018)
Fix #26723 Add `ChangeDefaultBranch` to the `notifier` interface and implement it in `indexerNotifier`. So when changing the default branch, `indexerNotifier` sends a message to the `indexer queue` to update the index. --------- Co-authored-by: techknowlogick <matti@mdranta.net>
Diffstat (limited to 'modules/indexer')
-rw-r--r--modules/indexer/code/git.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/indexer/code/git.go b/modules/indexer/code/git.go
index 1ba6b849d1..e4686fa01f 100644
--- a/modules/indexer/code/git.go
+++ b/modules/indexer/code/git.go
@@ -30,7 +30,14 @@ func getRepoChanges(ctx context.Context, repo *repo_model.Repository, revision s
return nil, err
}
- if len(status.CommitSha) == 0 {
+ needGenesis := len(status.CommitSha) == 0
+ if !needGenesis {
+ hasAncestorCmd := git.NewCommand(ctx, "merge-base").AddDynamicArguments(repo.CodeIndexerStatus.CommitSha, revision)
+ stdout, _, _ := hasAncestorCmd.RunStdString(&git.RunOpts{Dir: repo.RepoPath()})
+ needGenesis = len(stdout) == 0
+ }
+
+ if needGenesis {
return genesisChanges(ctx, repo, revision)
}
return nonGenesisChanges(ctx, repo, revision)