0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-30 18:22:02 +02:00
This commit is contained in:
Lunny Xiao 2026-05-22 23:19:33 -07:00
parent c69d373070
commit f69084ae70
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 23 additions and 2 deletions

View File

@ -277,6 +277,15 @@ func NewProjectWorkflowDoer(title string, workflowID int64, workflowEvent projec
}
}
// IsProjectWorkflowDoer reports whether the doer is the virtual project workflow actor.
func IsProjectWorkflowDoer(doer *user_model.User) bool {
if doer == nil {
return false
}
_, ok := doer.ExtDoerData.(*projectWorkflowDoer)
return ok
}
// Comment represents a comment in commit and issue page.
type Comment struct {
ID int64 `xorm:"pk autoincr"`

View File

@ -67,4 +67,7 @@ func TestBuildCreateCommentMetaData(t *testing.T) {
}
meta = buildCreateCommentMetaData(&CreateCommentOptions{Doer: nilMetaDoer})
assert.Nil(t, meta, "value-type projectWorkflowDoer must not match *projectWorkflowDoer type assertion")
assert.True(t, IsProjectWorkflowDoer(workflowDoer))
assert.False(t, IsProjectWorkflowDoer(nilMetaDoer))
assert.False(t, IsProjectWorkflowDoer(&user_model.User{ID: 1}))
}

View File

@ -73,7 +73,7 @@ func (m *workflowNotifier) NewPullRequest(ctx context.Context, pr *issues_model.
func (m *workflowNotifier) IssueChangeStatus(ctx context.Context, doer *user_model.User, commitID string, issue *issues_model.Issue, actionComment *issues_model.Comment, isClosed bool) {
// Skip state changes triggered by workflow actions to prevent cascade loops
// (same guard as feed/notifier.go).
if doer.ExtDoerData != nil {
if issues_model.IsProjectWorkflowDoer(doer) {
return
}
if err := issue.LoadRepo(ctx); err != nil {
@ -106,6 +106,9 @@ func (m *workflowNotifier) IssueChangeStatus(ctx context.Context, doer *user_mod
}
func (*workflowNotifier) IssueChangeProjects(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldProjectColumnMap map[int64]int64, newProjects []*project_model.Project) {
if issues_model.IsProjectWorkflowDoer(doer) {
return
}
addedProjects := make(map[int64]*project_model.Project)
for _, newProject := range newProjects {
// Use key presence check; column ID 0 is technically valid.
@ -166,7 +169,7 @@ func (*workflowNotifier) IssueChangeProjects(ctx context.Context, doer *user_mod
func (*workflowNotifier) IssueChangeProjectColumn(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldColumnID, newColumnID int64) {
// Skip column moves triggered by workflow actions to prevent cascade loops.
if doer.ExtDoerData != nil {
if issues_model.IsProjectWorkflowDoer(doer) {
return
}
if err := issue.LoadRepo(ctx); err != nil {
@ -219,6 +222,9 @@ func (*workflowNotifier) IssueChangeProjectColumn(ctx context.Context, doer *use
}
func (*workflowNotifier) MergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
if issues_model.IsProjectWorkflowDoer(doer) {
return
}
if err := pr.LoadIssue(ctx); err != nil {
log.Error("MergePullRequest: LoadIssue: %v", err)
return
@ -255,6 +261,9 @@ func (*workflowNotifier) MergePullRequest(ctx context.Context, doer *user_model.
}
func (m *workflowNotifier) AutoMergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
if issues_model.IsProjectWorkflowDoer(doer) {
return
}
m.MergePullRequest(ctx, doer, pr)
}