aboutsummaryrefslogtreecommitdiffstats
path: root/services
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 /services
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 'services')
-rw-r--r--services/indexer/notify.go9
-rw-r--r--services/notify/notifier.go2
-rw-r--r--services/notify/notify.go7
-rw-r--r--services/notify/null.go4
4 files changed, 22 insertions, 0 deletions
diff --git a/services/indexer/notify.go b/services/indexer/notify.go
index 22306c691b..a07bf38b06 100644
--- a/services/indexer/notify.go
+++ b/services/indexer/notify.go
@@ -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)
}
diff --git a/services/notify/notifier.go b/services/notify/notifier.go
index d1dbe44c11..ed053a812a 100644
--- a/services/notify/notifier.go
+++ b/services/notify/notifier.go
@@ -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)
}
diff --git a/services/notify/notify.go b/services/notify/notify.go
index 71bc1c7d58..16fbb6325d 100644
--- a/services/notify/notify.go
+++ b/services/notify/notify.go
@@ -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)
+ }
+}
diff --git a/services/notify/null.go b/services/notify/null.go
index c5b31f83d6..dddd421bef 100644
--- a/services/notify/null.go
+++ b/services/notify/null.go
@@ -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) {
+}