Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.15] Add support for listing merge requests associated with a commit #789

Open
wants to merge 1 commit into
base: 11.15
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Api/Repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ public function commitRefs($project_id, string $sha, array $parameters = [])
);
}

/**
* @param int|string $project_id
* @param string $sha
*
* @return mixed
*/
public function commitMergeRequests($project_id, string $sha)
{
return $this->get(
$this->getProjectPath($project_id, 'repository/commits/'.self::encodePath($sha).'/merge_requests'),
);
}

/**
* @param int|string $project_id
* @param array $parameters {
Expand Down
20 changes: 20 additions & 0 deletions tests/Api/RepositoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ public function shouldGetCommitRefs(): void
$this->assertEquals($expectedArray, $api->commitRefs(1, 'abcd1234'));
}

/**
* @test
*/
public function shouldGetCommitMergeRequests(): void
{
$expectedArray = [
['id' => 1, 'title' => 'A merge request'],
['id' => 2, 'title' => 'Another merge request'],
];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('projects/1/repository/commits/abcd1234/merge_requests')
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->commitMergeRequests(1, 'abcd1234'));
}

/**
* @test
*
Expand Down