mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package issue
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/git/models/db"
|
|
issues_model "github.com/hanzoai/git/models/issues"
|
|
user_model "github.com/hanzoai/git/models/user"
|
|
"github.com/hanzoai/git/modules/log"
|
|
notify_service "github.com/hanzoai/git/services/notify"
|
|
)
|
|
|
|
// CloseIssue close an issue.
|
|
func CloseIssue(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, commitID string) error {
|
|
var comment *issues_model.Comment
|
|
if err := db.WithTx(ctx, func(ctx context.Context) error {
|
|
var err error
|
|
comment, err = issues_model.CloseIssue(ctx, issue, doer)
|
|
if err != nil {
|
|
if issues_model.IsErrDependenciesLeft(err) {
|
|
if _, err := issues_model.FinishIssueStopwatch(ctx, doer, issue); err != nil {
|
|
log.Error("Unable to stop stopwatch for issue[%d]#%d: %v", issue.ID, issue.Index, err)
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
_, err = issues_model.FinishIssueStopwatch(ctx, doer, issue)
|
|
return err
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
notify_service.IssueChangeStatus(ctx, doer, commitID, issue, comment, true)
|
|
|
|
return nil
|
|
}
|
|
|
|
// ReopenIssue reopen an issue.
|
|
// FIXME: If some issues dependent this one are closed, should we also reopen them?
|
|
func ReopenIssue(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, commitID string) error {
|
|
comment, err := issues_model.ReopenIssue(ctx, issue, doer)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
notify_service.IssueChangeStatus(ctx, doer, commitID, issue, comment, false)
|
|
|
|
return nil
|
|
}
|