diff options
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/models/issue.go b/models/issue.go index cb5f8bb068..6d557ad4ef 100644 --- a/models/issue.go +++ b/models/issue.go @@ -93,6 +93,16 @@ func (issue *Issue) loadRepo(e Engine) (err error) { return nil } +// GetPullRequest returns the issue pull request +func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) { + if !issue.IsPull { + return nil, fmt.Errorf("Issue is not a pull request") + } + + pr, err = getPullRequestByIssueID(x, issue.ID) + return +} + func (issue *Issue) loadAttributes(e Engine) (err error) { if err := issue.loadRepo(e); err != nil { return err @@ -953,9 +963,9 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { switch opts.IsPull { case util.OptionalBoolTrue: - sess.And("issue.is_pull=?",true) + sess.And("issue.is_pull=?", true) case util.OptionalBoolFalse: - sess.And("issue.is_pull=?",false) + sess.And("issue.is_pull=?", false) } sortIssuesSession(sess, opts.SortType) @@ -1780,4 +1790,3 @@ func DeleteMilestoneByRepoID(repoID, id int64) error { } return sess.Commit() } - |