You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

status.go 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package issue
  4. import (
  5. "context"
  6. issues_model "code.gitea.io/gitea/models/issues"
  7. user_model "code.gitea.io/gitea/models/user"
  8. "code.gitea.io/gitea/modules/log"
  9. notify_service "code.gitea.io/gitea/services/notify"
  10. )
  11. // ChangeStatus changes issue status to open or closed.
  12. func ChangeStatus(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, commitID string, closed bool) error {
  13. comment, err := issues_model.ChangeIssueStatus(ctx, issue, doer, closed)
  14. if err != nil {
  15. if issues_model.IsErrDependenciesLeft(err) && closed {
  16. if err := issues_model.FinishIssueStopwatchIfPossible(ctx, doer, issue); err != nil {
  17. log.Error("Unable to stop stopwatch for issue[%d]#%d: %v", issue.ID, issue.Index, err)
  18. }
  19. }
  20. return err
  21. }
  22. if closed {
  23. if err := issues_model.FinishIssueStopwatchIfPossible(ctx, doer, issue); err != nil {
  24. return err
  25. }
  26. }
  27. notify_service.IssueChangeStatus(ctx, doer, commitID, issue, comment, closed)
  28. return nil
  29. }