Skip to content

Commit 7dc46ff

Browse files
authored
Match unqualified references when syncing pulls as well (#23070)
It seems that `opts.RefFullName` may occassionally be set to just the branch name, without the `refs/heads/` prefixing.
1 parent 3a7e095 commit 7dc46ff

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

modules/notification/indexer/indexer.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,19 @@ func (r *indexerNotifier) NotifyPushCommits(ctx context.Context, pusher *user_mo
135135
}
136136

137137
func (r *indexerNotifier) NotifySyncPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
138-
if setting.Indexer.RepoIndexerEnabled && opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
138+
// opts.RefFullName may occasionally be set to just the branch name, like 'master', without
139+
// the preceding 'refs/heads/` text, hence we match for both with and without the branch
140+
// prefix
141+
// e.g.
142+
// remote: Enumerating objects: 1544, done.
143+
// remote: Counting objects: 100% (1154/1154), done.
144+
// remote: Compressing objects: 100% (155/155), done.
145+
// remote: Total 1544 (delta 1022), reused 1078 (delta 996), pack-reused 390
146+
// Receiving objects: 100% (1544/1544), 2.16 MiB | 13.15 MiB/s, done.
147+
// Resolving deltas: 100% (1092/1092), completed with 439 local objects.
148+
// From https://github.com/go-gitea/gitea
149+
// 698188530..cf1a7b08e main -> origin/main
150+
if setting.Indexer.RepoIndexerEnabled && (opts.RefFullName == git.BranchPrefix+repo.DefaultBranch || opts.RefFullName == repo.DefaultBranch) {
139151
code_indexer.UpdateRepoIndexer(repo)
140152
}
141153
if err := stats_indexer.UpdateRepoIndexer(repo); err != nil {

0 commit comments

Comments
 (0)