0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-19 03:54:34 +01:00

Restore propagation of ErrDependenciesLeft (#18325)

Unfortunately #17643 prevented all propagation of ErrDependenciesLeft meaning
that dependency errors that prevent closing of issues get swallowed.

This PR restores propagation of the error but instead swallows the error in the
places where it needs to be swallowed.

Fix #18223

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2022-01-18 23:26:42 +00:00 committed by GitHub
parent 84f8ef3df6
commit 4a20eadfd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -8,6 +8,7 @@ import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/notification"
) )
@ -15,10 +16,9 @@ import (
func ChangeStatus(issue *models.Issue, doer *user_model.User, closed bool) error { func ChangeStatus(issue *models.Issue, doer *user_model.User, closed bool) error {
comment, err := issue.ChangeStatus(doer, closed) comment, err := issue.ChangeStatus(doer, closed)
if err != nil { if err != nil {
// Don't return an error when dependencies are open as this would let the push fail if models.IsErrDependenciesLeft(err) && closed {
if models.IsErrDependenciesLeft(err) { if err := models.FinishIssueStopwatchIfPossible(db.DefaultContext, doer, issue); err != nil {
if closed { log.Error("Unable to stop stopwatch for issue[%d]#%d: %v", issue.ID, issue.Index, err)
return models.FinishIssueStopwatchIfPossible(db.DefaultContext, doer, issue)
} }
} }
return err return err

View file

@ -105,10 +105,13 @@ func Merge(pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repos
close := ref.RefAction == references.XRefActionCloses close := ref.RefAction == references.XRefActionCloses
if close != ref.Issue.IsClosed { if close != ref.Issue.IsClosed {
if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil { if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil {
// Allow ErrDependenciesLeft
if !models.IsErrDependenciesLeft(err) {
return err return err
} }
} }
} }
}
return nil return nil
} }

View file

@ -514,7 +514,7 @@ func CloseBranchPulls(doer *user_model.User, repoID int64, branch string) error
var errs errlist var errs errlist
for _, pr := range prs { for _, pr := range prs {
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) { if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) && !models.IsErrDependenciesLeft(err) {
errs = append(errs, err) errs = append(errs, err)
} }
} }