mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 10:48:37 +00:00
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>
This commit is contained in:
@@ -110,6 +110,15 @@ func (r *indexerNotifier) SyncPushCommits(ctx context.Context, pusher *user_mode
|
||||
}
|
||||
}
|
||||
|
||||
func (r *indexerNotifier) ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) {
|
||||
if setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty {
|
||||
code_indexer.UpdateRepoIndexer(repo)
|
||||
}
|
||||
if err := stats_indexer.UpdateRepoIndexer(repo); err != nil {
|
||||
log.Error("stats_indexer.UpdateRepoIndexer(%d) failed: %v", repo.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *indexerNotifier) IssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) {
|
||||
issue_indexer.UpdateIssueIndexer(issue.ID)
|
||||
}
|
||||
|
@@ -72,4 +72,6 @@ type Notifier interface {
|
||||
|
||||
PackageCreate(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor)
|
||||
PackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor)
|
||||
|
||||
ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository)
|
||||
}
|
||||
|
@@ -360,3 +360,10 @@ func PackageDelete(ctx context.Context, doer *user_model.User, pd *packages_mode
|
||||
notifier.PackageDelete(ctx, doer, pd)
|
||||
}
|
||||
}
|
||||
|
||||
// ChangeDefaultBranch notifies change default branch to notifiers
|
||||
func ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) {
|
||||
for _, notifier := range notifiers {
|
||||
notifier.ChangeDefaultBranch(ctx, repo)
|
||||
}
|
||||
}
|
||||
|
@@ -204,3 +204,7 @@ func (*NullNotifier) PackageCreate(ctx context.Context, doer *user_model.User, p
|
||||
// PackageDelete places a place holder function
|
||||
func (*NullNotifier) PackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor) {
|
||||
}
|
||||
|
||||
// ChangeDefaultBranch places a place holder function
|
||||
func (*NullNotifier) ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) {
|
||||
}
|
||||
|
Reference in New Issue
Block a user