Skip to content

Commit 2537c8f

Browse files
committed
auto merge trigger by notifier
1 parent 9363b99 commit 2537c8f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

services/automerge/notify.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ package automerge
66
import (
77
"context"
88

9+
git_model "code.gitea.io/gitea/models/git"
910
issues_model "code.gitea.io/gitea/models/issues"
11+
repo_model "code.gitea.io/gitea/models/repo"
1012
user_model "code.gitea.io/gitea/models/user"
1113
"code.gitea.io/gitea/modules/log"
14+
"code.gitea.io/gitea/modules/repository"
1215
notify_service "code.gitea.io/gitea/services/notify"
1316
)
1417

@@ -44,3 +47,11 @@ func (n *automergeNotifier) PullReviewDismiss(ctx context.Context, doer *user_mo
4447
// as reviews could have blocked a pending automerge let's recheck
4548
StartPRCheckAndAutoMerge(ctx, review.Issue.PullRequest)
4649
}
50+
51+
func (m *automergeNotifier) CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, commit *repository.PushCommit, sender *user_model.User, status *git_model.CommitStatus) {
52+
if status.State.IsSuccess() {
53+
if err := StartPRCheckAndAutoMergeBySHA(ctx, commit.Sha1, repo); err != nil {
54+
log.Error("MergeScheduledPullRequest[repo_id: %d, user_id: %d, sha: %s]: %w", repo.ID, sender.ID, commit.Sha1, err)
55+
}
56+
}
57+
}

services/repository/commitstatus/commitstatus.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"code.gitea.io/gitea/modules/log"
2020
repo_module "code.gitea.io/gitea/modules/repository"
2121
api "code.gitea.io/gitea/modules/structs"
22-
"code.gitea.io/gitea/services/automerge"
2322
"code.gitea.io/gitea/services/notify"
2423
)
2524

@@ -115,12 +114,6 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato
115114

116115
notify.CreateCommitStatus(ctx, repo, repo_module.CommitToPushCommit(commit), creator, status)
117116

118-
if status.State.IsSuccess() {
119-
if err := automerge.StartPRCheckAndAutoMergeBySHA(ctx, sha, repo); err != nil {
120-
return fmt.Errorf("MergeScheduledPullRequest[repo_id: %d, user_id: %d, sha: %s]: %w", repo.ID, creator.ID, sha, err)
121-
}
122-
}
123-
124117
return nil
125118
}
126119

0 commit comments

Comments
 (0)