From 658d1bfac8c4706d83004c4069cd52ef63fb71cb Mon Sep 17 00:00:00 2001 From: Norwin Date: Sat, 13 Mar 2021 18:06:52 +0000 Subject: 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> --- routers/api/v1/repo/pull.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'routers') diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 8eda949652..e3be5b4af4 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -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, -- cgit v1.2.3