finish create issue with labels
This commit is contained in:
parent
17de3ab0a3
commit
922f3f3062
9 changed files with 160 additions and 41 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue