Skip to content

Commit 6123ed4

Browse files
committed
fix: dont create empy PR through API
1 parent e3e3260 commit 6123ed4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

routers/api/v1/repo/pull.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,13 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
12401240
return nil, nil, nil, "", ""
12411241
}
12421242

1243+
if !(len(compareInfo.Commits) > 0) {
1244+
headGitRepo.Close()
1245+
ctx.Error(http.StatusUnprocessableEntity, "EmptyPullRequest",
1246+
fmt.Sprintf("no commits between %v:%v and %v:%v", baseRepo.Owner.Name, baseBranch, headUser.Name, headBranch))
1247+
return nil, nil, nil, "", ""
1248+
}
1249+
12431250
return headRepo, headGitRepo, compareInfo, baseBranch, headBranch
12441251
}
12451252

0 commit comments

Comments
 (0)