Skip to content

Commit d5ed63c

Browse files
authored
fix: pass gitlab mergerequest param via json body (#322)
Signed-off-by: Olivier Vernin <[email protected]>
1 parent 7dc2e34 commit d5ed63c

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

scm/driver/gitlab/pr.go

+16-7
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,23 @@ func (s *pullService) ListCommits(ctx context.Context, repo string, number int,
6060
}
6161

6262
func (s *pullService) Create(ctx context.Context, repo string, input *scm.PullRequestInput) (*scm.PullRequest, *scm.Response, error) {
63-
in := url.Values{}
64-
in.Set("title", input.Title)
65-
in.Set("description", input.Body)
66-
in.Set("source_branch", input.Source)
67-
in.Set("target_branch", input.Target)
68-
path := fmt.Sprintf("api/v4/projects/%s/merge_requests?%s", encode(repo), in.Encode())
63+
// https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
64+
in := struct {
65+
Title string `json:"title"`
66+
Description string `json:"description"`
67+
SourceBranch string `json:"source_branch"`
68+
TargetBranch string `json:"target_branch"`
69+
}{
70+
Title: input.Title,
71+
Description: input.Body,
72+
SourceBranch: input.Source,
73+
TargetBranch: input.Target,
74+
}
75+
76+
path := fmt.Sprintf("api/v4/projects/%s/merge_requests", encode(repo))
77+
6978
out := new(pr)
70-
res, err := s.client.do(ctx, "POST", path, nil, out)
79+
res, err := s.client.do(ctx, "POST", path, in, out)
7180
return convertPullRequest(out), res, err
7281
}
7382

scm/driver/gitlab/pr_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ func TestPullCreate(t *testing.T) {
162162

163163
gock.New("https://gitlab.com").
164164
Post("/api/v4/projects/diaspora/diaspora/merge_requests").
165-
MatchParam("title", input.Title).
166-
MatchParam("description", input.Body).
167-
MatchParam("source_branch", input.Source).
168-
MatchParam("target_branch", input.Target).
169165
Reply(201).
170166
Type("application/json").
171167
SetHeaders(mockHeaders).

0 commit comments

Comments
 (0)