mirror of
https://github.com/go-gitea/gitea
synced 2025-07-05 10:07:22 +00:00
Use CloseIssue
and ReopenIssue
instead of ChangeStatus
(#32467)
The behaviors of closing issues and reopening issues are very different. So splitting it into two different functions makes it easier to maintain. - [x] Split ChangeIssueStatus into CloseIssue and ReopenIssue both at the service layer and model layer - [x] Rename `isClosed` to `CloseOrReopen` to make it more readable. - [x] Add transactions for ReopenIssue and CloseIssue --------- Co-authored-by: Zettat123 <zettat123@gmail.com>
This commit is contained in:
@ -188,15 +188,19 @@ func UpdateIssuesCommit(ctx context.Context, doer *user_model.User, repo *repo_m
|
||||
continue
|
||||
}
|
||||
}
|
||||
isClosed := ref.Action == references.XRefActionCloses
|
||||
if isClosed && len(ref.TimeLog) > 0 {
|
||||
if err := issueAddTime(ctx, refIssue, doer, c.Timestamp, ref.TimeLog); err != nil {
|
||||
|
||||
refIssue.Repo = refRepo
|
||||
if ref.Action == references.XRefActionCloses && !refIssue.IsClosed {
|
||||
if len(ref.TimeLog) > 0 {
|
||||
if err := issueAddTime(ctx, refIssue, doer, c.Timestamp, ref.TimeLog); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := CloseIssue(ctx, refIssue, doer, c.Sha1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if isClosed != refIssue.IsClosed {
|
||||
refIssue.Repo = refRepo
|
||||
if err := ChangeStatus(ctx, refIssue, doer, c.Sha1, isClosed); err != nil {
|
||||
} else if ref.Action == references.XRefActionReopens && refIssue.IsClosed {
|
||||
if err := ReopenIssue(ctx, refIssue, doer, c.Sha1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user