Skip to content

Commit f4247d7

Browse files
author
Matt Humphrey
committed
Added merge request changes endpoint. Fixes #69
1 parent 96f91c9 commit f4247d7

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

lib/Gitlab/Api/MergeRequests.php

+10
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ public function addComment($project_id, $mr_id, $note)
132132
));
133133
}
134134

135+
/**
136+
* @param int $project_id
137+
* @param int $mr_id
138+
* @return mixed
139+
*/
140+
public function changes($project_id, $mr_id)
141+
{
142+
return $this->get($this->getProjectPath($project_id, 'merge_request/'.urlencode($mr_id).'/changes'));
143+
}
144+
135145
/**
136146
* @param int $project_id
137147
* @param int $page

lib/Gitlab/Model/MergeRequest.php

+28-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* @property-read User $author
2323
* @property-read User $assignee
2424
* @property-read Project $project
25+
* @property-read Milestone $milestone
26+
* @property-read File[] $files
2527
*/
2628
class MergeRequest extends AbstractModel implements Noteable
2729
{
@@ -45,7 +47,9 @@ class MergeRequest extends AbstractModel implements Noteable
4547
'target_project_id',
4648
'upvotes',
4749
'downvotes',
48-
'labels'
50+
'labels',
51+
'milestone',
52+
'files'
4953
);
5054

5155
/**
@@ -66,6 +70,19 @@ public static function fromArray(Client $client, Project $project, array $data)
6670
$data['assignee'] = User::fromArray($client, $data['assignee']);
6771
}
6872

73+
if (isset($data['milestone'])) {
74+
$data['milestone'] = Milestone::fromArray($client, $project, $data['milestone']);
75+
}
76+
77+
if (isset($data['files'])) {
78+
$files = array();
79+
foreach ($data['files'] as $file) {
80+
$files[] = File::fromArray($client, $project, $file);
81+
}
82+
83+
$data['files'] = $files;
84+
}
85+
6986
return $mr->hydrate($data);
7087
}
7188

@@ -195,4 +212,14 @@ public function isClosed()
195212

196213
return false;
197214
}
215+
216+
/**
217+
* @return MergeRequest
218+
*/
219+
public function changes()
220+
{
221+
$data = $this->api('mr')->changes($this->project->id, $this->id);
222+
223+
return static::fromArray($this->getClient(), $this->project, $data);
224+
}
198225
}

0 commit comments

Comments
 (0)