@@ -12,14 +12,14 @@ class MergeRequests extends AbstractApi
12
12
13
13
/**
14
14
* @param int $project_id
15
+ * @param string $state
15
16
* @param int $page
16
17
* @param int $per_page
17
- * @param string $state
18
18
* @param string $order_by
19
19
* @param string $sort
20
20
* @return mixed
21
21
*/
22
- public function getList ($ project_id , $ page , $ per_page , $ state = self ::STATE_ALL , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
22
+ public function getList ($ project_id , $ state = self :: STATE_ALL , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
23
23
{
24
24
return $ this ->get ($ this ->getProjectPath ($ project_id , 'merge_requests ' ), array (
25
25
'page ' => $ page ,
@@ -40,7 +40,7 @@ public function getList($project_id, $page, $per_page, $state = self::STATE_ALL,
40
40
*/
41
41
public function all ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
42
42
{
43
- return $ this ->getList ($ project_id , $ page , $ per_page, self :: STATE_ALL , $ order_by , $ sort );
43
+ return $ this ->getList ($ project_id , self :: STATE_ALL , $ page , $ per_page , $ order_by , $ sort );
44
44
}
45
45
46
46
/**
@@ -53,7 +53,7 @@ public function all($project_id, $page = 1, $per_page = self::PER_PAGE, $order_b
53
53
*/
54
54
public function merged ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
55
55
{
56
- return $ this ->getList ($ project_id , $ page , $ per_page, self :: STATE_MERGED , $ order_by , $ sort );
56
+ return $ this ->getList ($ project_id , self :: STATE_MERGED , $ page , $ per_page , $ order_by , $ sort );
57
57
}
58
58
59
59
/**
@@ -66,7 +66,7 @@ public function merged($project_id, $page = 1, $per_page = self::PER_PAGE, $orde
66
66
*/
67
67
public function opened ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
68
68
{
69
- return $ this ->getList ($ project_id , $ page , $ per_page, self :: STATE_OPENED , $ order_by , $ sort );
69
+ return $ this ->getList ($ project_id , self :: STATE_OPENED , $ page , $ per_page , $ order_by , $ sort );
70
70
}
71
71
72
72
/**
@@ -79,7 +79,7 @@ public function opened($project_id, $page = 1, $per_page = self::PER_PAGE, $orde
79
79
*/
80
80
public function closed ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
81
81
{
82
- return $ this ->getList ($ project_id , $ page , $ per_page, self :: STATE_CLOSED , $ order_by , $ sort );
82
+ return $ this ->getList ($ project_id , self :: STATE_CLOSED , $ page , $ per_page , $ order_by , $ sort );
83
83
}
84
84
85
85
/**
@@ -104,10 +104,6 @@ public function show($project_id, $mr_id)
104
104
*/
105
105
public function create ($ project_id , $ source , $ target , $ title , $ assignee = null , $ target_project_id = null , $ description = null )
106
106
{
107
- if ($ target_project_id && ! is_numeric ($ target_project_id )) {
108
- throw new \InvalidArgumentException ('target_project_id should be numeric, the project name is not allowed ' );
109
- }
110
-
111
107
return $ this ->post ($ this ->getProjectPath ($ project_id , 'merge_requests ' ), array (
112
108
'source_branch ' => $ source ,
113
109
'target_branch ' => $ target ,
@@ -132,11 +128,17 @@ public function update($project_id, $mr_id, array $params)
132
128
/**
133
129
* @param int $project_id
134
130
* @param int $mr_id
135
- * @param array $params
131
+ * @param string $message
136
132
* @return mixed
137
133
*/
138
- public function merge ($ project_id , $ mr_id , array $ params )
134
+ public function merge ($ project_id , $ mr_id , $ message = null )
139
135
{
136
+ if (is_array ($ message )) {
137
+ $ params = $ message ;
138
+ } else {
139
+ $ params = array ('merge_commit_message ' => $ message );
140
+ }
141
+
140
142
return $ this ->put ($ this ->getProjectPath ($ project_id , 'merge_request/ ' .urlencode ($ mr_id ).'/merge ' ), $ params );
141
143
}
142
144
0 commit comments