Skip to content

Commit

Permalink
feature #1074 Add method to use generate release notes endpoint (GuyS…
Browse files Browse the repository at this point in the history
…artorelli)

This PR was merged into the 3.4.x-dev branch.

Discussion
----------

Adds a method for https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release

Commits
-------

2354dce Add method to use generate release notes endpoint
  • Loading branch information
acrobat authored Jul 30, 2022
2 parents d90368c + 2354dce commit 994c5e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Github/Api/Repository/Releases.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ public function show($username, $repository, $id)
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id);
}

/**
* Generate release notes content for a release.
*
* @param string $username
* @param string $repository
* @param array $params
*
* @return array
*/
public function generateNotes($username, $repository, array $params)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/generate-notes', $params);
}

/**
* Create new release in selected repository.
*
Expand Down
20 changes: 20 additions & 0 deletions test/Github/Tests/Api/Repository/ReleasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ public function shouldGetSingleRepositoryRelease()
$this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $id));
}

/**
* @test
*/
public function shouldGenerateReleaseNotes()
{
$expectedValue = [
'name' => 'Release v1.0.0 is now available!',
'body' => '##Changes in Release v1.0.0 ... ##Contributors @monalisa',
];
$data = ['tag_name' => 'some-tag'];

$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/releases/generate-notes')
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->generateNotes('KnpLabs', 'php-github-api', $data));
}

/**
* @test
*/
Expand Down

0 comments on commit 994c5e3

Please sign in to comment.