diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-06-13 17:37:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-13 17:37:59 +0800 |
commit | 1a9821f57a0293db3adc0eab8aff08ca5fa1026c (patch) | |
tree | 3c3d02813eb63c0d0827ef6d9745f6dcdd2636cb /services/issue/label.go | |
parent | 3708ca8e2849ca7e36e6bd15ec6935a2a2d81e55 (diff) | |
download | gitea-1a9821f57a0293db3adc0eab8aff08ca5fa1026c.tar.gz gitea-1a9821f57a0293db3adc0eab8aff08ca5fa1026c.zip |
Move issues related files into models/issues (#19931)
* Move access and repo permission to models/perm/access
* fix test
* fix git test
* Move functions sequence
* Some improvements per @KN4CK3R and @delvh
* Move issues related code to models/issues
* Move some issues related sub package
* Merge
* Fix test
* Fix test
* Fix test
* Fix test
* Rename some files
Diffstat (limited to 'services/issue/label.go')
-rw-r--r-- | services/issue/label.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/services/issue/label.go b/services/issue/label.go index 289466f604..bc5f9b910e 100644 --- a/services/issue/label.go +++ b/services/issue/label.go @@ -5,16 +5,16 @@ package issue import ( - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + issues_model "code.gitea.io/gitea/models/issues" access_model "code.gitea.io/gitea/models/perm/access" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/notification" ) // ClearLabels clears all of an issue's labels -func ClearLabels(issue *models.Issue, doer *user_model.User) (err error) { - if err = models.ClearIssueLabels(issue, doer); err != nil { +func ClearLabels(issue *issues_model.Issue, doer *user_model.User) (err error) { + if err = issues_model.ClearIssueLabels(issue, doer); err != nil { return } @@ -24,18 +24,18 @@ func ClearLabels(issue *models.Issue, doer *user_model.User) (err error) { } // AddLabel adds a new label to the issue. -func AddLabel(issue *models.Issue, doer *user_model.User, label *models.Label) error { - if err := models.NewIssueLabel(issue, label, doer); err != nil { +func AddLabel(issue *issues_model.Issue, doer *user_model.User, label *issues_model.Label) error { + if err := issues_model.NewIssueLabel(issue, label, doer); err != nil { return err } - notification.NotifyIssueChangeLabels(doer, issue, []*models.Label{label}, nil) + notification.NotifyIssueChangeLabels(doer, issue, []*issues_model.Label{label}, nil) return nil } // AddLabels adds a list of new labels to the issue. -func AddLabels(issue *models.Issue, doer *user_model.User, labels []*models.Label) error { - if err := models.NewIssueLabels(issue, labels, doer); err != nil { +func AddLabels(issue *issues_model.Issue, doer *user_model.User, labels []*issues_model.Label) error { + if err := issues_model.NewIssueLabels(issue, labels, doer); err != nil { return err } @@ -44,7 +44,7 @@ func AddLabels(issue *models.Issue, doer *user_model.User, labels []*models.Labe } // RemoveLabel removes a label from issue by given ID. -func RemoveLabel(issue *models.Issue, doer *user_model.User, label *models.Label) error { +func RemoveLabel(issue *issues_model.Issue, doer *user_model.User, label *issues_model.Label) error { ctx, committer, err := db.TxContext() if err != nil { return err @@ -61,12 +61,12 @@ func RemoveLabel(issue *models.Issue, doer *user_model.User, label *models.Label } if !perm.CanWriteIssuesOrPulls(issue.IsPull) { if label.OrgID > 0 { - return models.ErrOrgLabelNotExist{} + return issues_model.ErrOrgLabelNotExist{} } - return models.ErrRepoLabelNotExist{} + return issues_model.ErrRepoLabelNotExist{} } - if err := models.DeleteIssueLabel(ctx, issue, label, doer); err != nil { + if err := issues_model.DeleteIssueLabel(ctx, issue, label, doer); err != nil { return err } @@ -74,18 +74,18 @@ func RemoveLabel(issue *models.Issue, doer *user_model.User, label *models.Label return err } - notification.NotifyIssueChangeLabels(doer, issue, nil, []*models.Label{label}) + notification.NotifyIssueChangeLabels(doer, issue, nil, []*issues_model.Label{label}) return nil } // ReplaceLabels removes all current labels and add new labels to the issue. -func ReplaceLabels(issue *models.Issue, doer *user_model.User, labels []*models.Label) error { - old, err := models.GetLabelsByIssueID(db.DefaultContext, issue.ID) +func ReplaceLabels(issue *issues_model.Issue, doer *user_model.User, labels []*issues_model.Label) error { + old, err := issues_model.GetLabelsByIssueID(db.DefaultContext, issue.ID) if err != nil { return err } - if err := models.ReplaceIssueLabels(issue, labels, doer); err != nil { + if err := issues_model.ReplaceIssueLabels(issue, labels, doer); err != nil { return err } |