Skip to content

Commit 0a299df

Browse files
committed
Fix GetPullRequestByIndex
* validate index Signed-off-by: Danila Kryukov <[email protected]>
1 parent f4ea6cc commit 0a299df

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

models/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ func GetLatestPullRequestByHeadInfo(repoID int64, branch string) (*PullRequest,
522522

523523
// GetPullRequestByIndex returns a pull request by the given index
524524
func GetPullRequestByIndex(repoID, index int64) (*PullRequest, error) {
525+
if index < 1 {
526+
return nil, ErrPullRequestNotExist{}
527+
}
525528
pr := &PullRequest{
526529
BaseRepoID: repoID,
527530
Index: index,

0 commit comments

Comments
 (0)