diff options
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/models/pull.go b/models/pull.go index 2f5412651b..eac36235bb 100644 --- a/models/pull.go +++ b/models/pull.go @@ -776,6 +776,20 @@ func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequ Find(&prs) } +// GetLatestPullRequestByHeadInfo returns the latest pull request (regardless of its status) +// by given head information (repo and branch). +func GetLatestPullRequestByHeadInfo(repoID int64, branch string) (*PullRequest, error) { + pr := new(PullRequest) + has, err := x. + Where("head_repo_id = ? AND head_branch = ?", repoID, branch). + OrderBy("id DESC"). + Get(pr) + if !has { + return nil, err + } + return pr, err +} + // GetUnmergedPullRequestsByBaseInfo returns all pull requests that are open and has not been merged // by given base information (repo and branch). func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequest, error) { |