1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 23:17:19 +00:00

API: fix set milestone on PR creation (#14981)

* API: fix set milestone on PR creation

pr creation via API failed with 404, because we searched
for milestoneID 0, due to uninitialized var usage D:

* add tests

* fix expected status codes

* fix tests

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Norwin
2021-03-13 18:06:52 +00:00
committed by GitHub
parent e256a62257
commit 658d1bfac8
5 changed files with 91 additions and 5 deletions

View File

@@ -295,7 +295,6 @@ func CreatePullRequest(ctx *context.APIContext) {
var (
repo = ctx.Repo.Repository
labelIDs []int64
assigneeID int64
milestoneID int64
)
@@ -356,7 +355,7 @@ func CreatePullRequest(ctx *context.APIContext) {
}
if form.Milestone > 0 {
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, milestoneID)
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, form.Milestone)
if err != nil {
if models.IsErrMilestoneNotExist(err) {
ctx.NotFound()
@@ -380,7 +379,6 @@ func CreatePullRequest(ctx *context.APIContext) {
PosterID: ctx.User.ID,
Poster: ctx.User,
MilestoneID: milestoneID,
AssigneeID: assigneeID,
IsPull: true,
Content: form.Body,
DeadlineUnix: deadlineUnix,