mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Fix close issue but time watcher still running (#17643)
* Fix close issue but time watcher still running * refactor stopwatch codes * Fix test * Fix test * Fix typo * Fix test
This commit is contained in:
		@@ -6,16 +6,30 @@ package issue
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"code.gitea.io/gitea/models"
 | 
			
		||||
	"code.gitea.io/gitea/models/db"
 | 
			
		||||
	"code.gitea.io/gitea/modules/notification"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ChangeStatus changes issue status to open or closed.
 | 
			
		||||
func ChangeStatus(issue *models.Issue, doer *models.User, isClosed bool) (err error) {
 | 
			
		||||
	comment, err := issue.ChangeStatus(doer, isClosed)
 | 
			
		||||
func ChangeStatus(issue *models.Issue, doer *models.User, closed bool) error {
 | 
			
		||||
	comment, err := issue.ChangeStatus(doer, closed)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return
 | 
			
		||||
		// Don't return an error when dependencies are open as this would let the push fail
 | 
			
		||||
		if models.IsErrDependenciesLeft(err) {
 | 
			
		||||
			if closed {
 | 
			
		||||
				return models.FinishIssueStopwatchIfPossible(db.DefaultContext, doer, issue)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	notification.NotifyIssueChangeStatus(doer, issue, comment, isClosed)
 | 
			
		||||
	if closed {
 | 
			
		||||
		if err := models.FinishIssueStopwatchIfPossible(db.DefaultContext, doer, issue); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	notification.NotifyIssueChangeStatus(doer, issue, comment, closed)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user