Skip to content

Commit 3dd0832

Browse files
authored
feature KnpLabs#1032 Added dir parameter for Repo readme (AlexandrePavy)
This PR was merged into the 3.4.x-dev branch. Discussion ---------- Hello Following this documentation : https://docs.github.com/en/rest/reference/repos#get-a-repository-readme-for-a-directory We can add `dir` (optional) parameter to fetch a README in specific folder. Commits ------- f6123b0 Added dir parameter for Repo readme
2 parents fe55989 + f6123b0 commit 3dd0832

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Github/Api/Repo.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,20 @@ public function remove($username, $repository)
257257
* @param string $username the user who owns the repository
258258
* @param string $repository the name of the repository
259259
* @param string $format one of formats: "raw", "html", or "v3+json"
260+
* @param string $dir The alternate path to look for a README file
260261
* @param array $params additional query params like "ref" to fetch readme for branch/tag
261262
*
262263
* @return string|array the readme content
263264
*/
264-
public function readme($username, $repository, $format = 'raw', $params = [])
265+
public function readme($username, $repository, $format = 'raw', $dir = null, $params = [])
265266
{
266-
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme', $params, [
267+
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme';
268+
269+
if (null !== $dir) {
270+
$path .= '/'.rawurlencode($dir);
271+
}
272+
273+
return $this->get($path, $params, [
267274
'Accept' => "application/vnd.github.$format",
268275
]);
269276
}

0 commit comments

Comments
 (0)