Skip to content

Commit 3fb3a86

Browse files
spawniam1guelpf
authored andcommitted
Allow passing arbitrary additional options to MergeRequests#create()
1 parent bb81a99 commit 3fb3a86

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

lib/Gitlab/Api/MergeRequests.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,27 @@ public function show($project_id, $mr_id)
109109
* @param string $source
110110
* @param string $target
111111
* @param string $title
112-
* @param int $assignee
113-
* @param int $target_project_id
114-
* @param string $description
112+
* @param int $assignee @deprecated will be moved into $optionalParams
113+
* @param int $target_project_id @deprecated will be moved into $optionalParams
114+
* @param string $description @deprecated will be moved into $optionalParams
115+
* @param array $optionalParams
115116
* @return mixed
116117
*/
117-
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null)
118+
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null, array $optionalParams = [])
118119
{
119-
return $this->post($this->getProjectPath($project_id, 'merge_requests'), array(
120+
$baseParams = [
120121
'source_branch' => $source,
121122
'target_branch' => $target,
122123
'title' => $title,
123124
'assignee_id' => $assignee,
125+
'description' => $description,
124126
'target_project_id' => $target_project_id,
125-
'description' => $description
126-
));
127+
];
128+
129+
return $this->post(
130+
$this->getProjectPath($project_id, 'merge_requests'),
131+
array_merge($baseParams, $optionalParams)
132+
);
127133
}
128134

129135
/**

test/Gitlab/Tests/Api/MergeRequestsTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,27 @@ public function shouldCreateMergeRequestWithOptionalParams()
147147
'title' => 'Merge Request',
148148
'target_branch' => 'master',
149149
'source_branch' => 'develop',
150-
'description' => 'Some changes',
151150
'assignee_id' => 6,
152-
'target_project_id' => 20
151+
'target_project_id' => 20,
152+
'description' => 'Some changes',
153+
'remove_source_branch' => true,
153154
))
154155
->will($this->returnValue($expectedArray))
155156
;
156157

157-
$this->assertEquals($expectedArray, $api->create(1, 'develop', 'master', 'Merge Request', 6, 20, 'Some changes'));
158+
$this->assertEquals(
159+
$expectedArray,
160+
$api->create(
161+
1,
162+
'develop',
163+
'master',
164+
'Merge Request',
165+
6,
166+
20,
167+
'Some changes',
168+
['remove_source_branch' => true]
169+
)
170+
);
158171
}
159172

160173
/**

0 commit comments

Comments
 (0)