Skip to content

Commit 334e1fd

Browse files
Merge branch '9.18' into 9.19
2 parents c7c6856 + 5fcbc55 commit 334e1fd

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed

lib/Gitlab/Api/Issues.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,17 @@ public function closedByMergeRequests($project_id, $issue_iid)
469469
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by');
470470
}
471471

472+
/**
473+
* @param int|string $project_id
474+
* @param int $issue_iid
475+
*
476+
* @return mixed
477+
*/
478+
public function relatedMergeRequests($project_id, $issue_iid)
479+
{
480+
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/related_merge_requests'));
481+
}
482+
472483
/**
473484
* @param int|string $project_id
474485
* @param int $issue_iid

lib/Gitlab/Api/Projects.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,25 @@ public function boards($project_id)
521521
return $this->get($this->getProjectPath($project_id, 'boards'));
522522
}
523523

524+
/**
525+
* Gets a list of all discussion items for a single commit.
526+
*
527+
* Example:
528+
* - https://gitlab.com/gitlab-org/gitlab/-/commit/695c29abcf7dc2eabde8d59869abcea0923ce8fa#note_334686748
529+
* - https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/commits/695c29abcf7dc2eabde8d59869abcea0923ce8fa/discussions
530+
*
531+
* @see https://docs.gitlab.com/ee/api/discussions.html#list-project-commit-discussion-items
532+
*
533+
* @param int|string $project_id
534+
* @param string $commit_id
535+
*
536+
* @return mixed
537+
*/
538+
public function getRepositoryCommitDiscussions($project_id, $commit_id)
539+
{
540+
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($commit_id)).'/discussions');
541+
}
542+
524543
/**
525544
* @param int|string $project_id
526545
* @param string $url

lib/Gitlab/Api/Repositories.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function releases($project_id)
168168
}
169169

170170
/**
171+
* @see https://docs.gitlab.com/ee/api/commits.html#list-repository-commits
172+
*
171173
* @param int|string $project_id
172174
* @param array $parameters {
173175
*
@@ -184,6 +186,9 @@ public function commits($project_id, array $parameters = [])
184186
$datetimeNormalizer = function (Options $options, \DateTimeInterface $value) {
185187
return $value->format('c');
186188
};
189+
$booleanNormalizer = function (Options $resolver, $value) {
190+
return $value ? 'true' : 'false';
191+
};
187192

188193
$resolver->setDefined('path');
189194
$resolver->setDefined('ref_name');
@@ -195,8 +200,21 @@ public function commits($project_id, array $parameters = [])
195200
->setAllowedTypes('until', \DateTimeInterface::class)
196201
->setNormalizer('until', $datetimeNormalizer)
197202
;
198-
$resolver->setDefined('all');
199-
$resolver->setDefined('with_stats');
203+
$resolver->setDefined('all')
204+
->setAllowedTypes('all', 'bool')
205+
->setNormalizer('all', $booleanNormalizer)
206+
;
207+
$resolver->setDefined('with_stats')
208+
->setAllowedTypes('with_stats', 'bool')
209+
->setNormalizer('with_stats', $booleanNormalizer)
210+
;
211+
$resolver->setDefined('first_parent')
212+
->setAllowedTypes('first_parent', 'bool')
213+
->setNormalizer('first_parent', $booleanNormalizer)
214+
;
215+
$resolver->setDefined('order')
216+
->setAllowedTypes('order', ['default', 'topo'])
217+
;
200218

201219
return $this->get($this->getProjectPath($project_id, 'repository/commits'), $resolver->resolve($parameters));
202220
}

test/Gitlab/Tests/Api/IssuesTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,26 @@ public function shouldGetIssueClosedByMergeRequests()
601601
$this->assertEquals($expectedArray, $api->closedByMergeRequests(1, 2));
602602
}
603603

604+
/**
605+
* @test
606+
*/
607+
public function shouldGetIssueRelatedMergeRequests()
608+
{
609+
$expectedArray = [
610+
['id' => 1, 'iid' => '1111', 'title' => 'Just saving the world'],
611+
['id' => 2, 'iid' => '1112', 'title' => 'Adding new feature to get merge requests that close an issue'],
612+
];
613+
614+
$api = $this->getApiMock();
615+
$api->expects($this->once())
616+
->method('get')
617+
->with('projects/1/issues/2/related_merge_requests')
618+
->will($this->returnValue($expectedArray))
619+
;
620+
621+
$this->assertEquals($expectedArray, $api->relatedMergeRequests(1, 2));
622+
}
623+
604624
/**
605625
* @test
606626
*/

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public function shouldGetCommitsWithParams()
277277
$api = $this->getApiMock();
278278
$api->expects($this->once())
279279
->method('get')
280-
->with('projects/1/repository/commits', ['page' => 2, 'per_page' => 25, 'ref_name' => 'master', 'all' => true, 'with_stats' => true, 'path' => 'file_path/file_name'])
280+
->with('projects/1/repository/commits', ['page' => 2, 'per_page' => 25, 'ref_name' => 'master', 'all' => 'true', 'with_stats' => 'true', 'path' => 'file_path/file_name'])
281281
->will($this->returnValue($expectedArray))
282282
;
283283

0 commit comments

Comments
 (0)