summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-01-31 20:31:35 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-01 09:31:35 +0800
commit10644d6dd7574b031118bf01b2bd737017230ffd (patch)
tree42f4fa34184145defb2237a78306c6da3c1ed3bd /models/issue_label.go
parent0a02fb3c4fc241aca54e4ec62e4029e6db3be3f9 (diff)
downloadgitea-10644d6dd7574b031118bf01b2bd737017230ffd.tar.gz
gitea-10644d6dd7574b031118bf01b2bd737017230ffd.zip
Bug fixes and unit tests for models/issue_label (#802)
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 02397f146f..970b3fcc4c 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -114,7 +114,7 @@ func getLabelInRepoByName(e Engine, repoID int64, labelName string) (*Label, err
Name: labelName,
RepoID: repoID,
}
- has, err := x.Get(l)
+ has, err := e.Get(l)
if err != nil {
return nil, err
} else if !has {
@@ -135,7 +135,7 @@ func getLabelInRepoByID(e Engine, repoID, labelID int64) (*Label, error) {
ID: labelID,
RepoID: repoID,
}
- has, err := x.Get(l)
+ has, err := e.Get(l)
if err != nil {
return nil, err
} else if !has {
@@ -355,17 +355,14 @@ func getIssueLabels(e Engine, issueID int64) ([]*IssueLabel, error) {
Find(&issueLabels)
}
-// GetIssueLabels returns all issue-label relations of given issue by ID.
-func GetIssueLabels(issueID int64) ([]*IssueLabel, error) {
- return getIssueLabels(x, issueID)
-}
-
-func deleteIssueLabel(e *xorm.Session, doer *User, issue *Issue, label *Label) (err error) {
- if _, err = e.Delete(&IssueLabel{
+func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (err error) {
+ if count, err := e.Delete(&IssueLabel{
IssueID: issue.ID,
LabelID: label.ID,
}); err != nil {
return err
+ } else if count == 0 {
+ return nil
}
if err = issue.loadRepo(e); err != nil {
@@ -384,14 +381,14 @@ func deleteIssueLabel(e *xorm.Session, doer *User, issue *Issue, label *Label) (
}
// DeleteIssueLabel deletes issue-label relation.
-func DeleteIssueLabel(issue *Issue, doer *User, label *Label) (err error) {
+func DeleteIssueLabel(issue *Issue, label *Label, doer *User) (err error) {
sess := x.NewSession()
defer sessionRelease(sess)
if err = sess.Begin(); err != nil {
return err
}
- if err = deleteIssueLabel(sess, doer, issue, label); err != nil {
+ if err = deleteIssueLabel(sess, issue, label, doer); err != nil {
return err
}