diff options
author | Unknwon <u@gogs.io> | 2015-08-10 16:52:08 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-10 16:52:08 +0800 |
commit | 922f3f306239aca309279dbdf1bdedfb9788b6e8 (patch) | |
tree | 410c6eb28335f9e0a213da59699053b159f607ea /models | |
parent | 17de3ab0a313819bdeb73f3985b61a791ae84696 (diff) | |
download | gitea-922f3f306239aca309279dbdf1bdedfb9788b6e8.tar.gz gitea-922f3f306239aca309279dbdf1bdedfb9788b6e8.zip |
finish create issue with labels
Diffstat (limited to 'models')
-rw-r--r-- | models/issue.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go index 892b9928c0..de8a4f5346 100644 --- a/models/issue.go +++ b/models/issue.go @@ -144,8 +144,8 @@ func (i *Issue) AfterDelete() { } } -// CreateIssue creates new issue for repository. -func NewIssue(issue *Issue) (err error) { +// CreateIssue creates new issue with labels for repository. +func NewIssue(issue *Issue, labelIDs []int64) (err error) { sess := x.NewSession() defer sessionRelease(sess) if err = sess.Begin(); err != nil { @@ -158,6 +158,12 @@ func NewIssue(issue *Issue) (err error) { return err } + for _, id := range labelIDs { + if err = issue.addLabel(sess, id); err != nil { + return fmt.Errorf("addLabel: %v", err) + } + } + if err = sess.Commit(); err != nil { return err } @@ -688,6 +694,10 @@ func HasIssueLabel(issueID, labelID int64) bool { } func newIssueLabel(e Engine, issueID, labelID int64) error { + if issueID == 0 || labelID == 0 { + return nil + } + _, err := e.Insert(&IssueLabel{ IssueID: issueID, LabelID: labelID, |