Skip to content

Commit 8a8f304

Browse files
committed
Merge pull request #62 from Future500BV/repo-create
Added new parameters for creating a repository
2 parents 86d58f6 + 4f62c81 commit 8a8f304

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

lib/Github/Api/Repo.php

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,49 @@ public function show($username, $repository)
5555
* Create repository
5656
* @link http://developer.github.com/v3/repos/
5757
*
58-
* @param string $name name of the repository
59-
* @param string $description repository description
60-
* @param string $homepage homepage url
61-
* @param boolean $public `true` for public, `false` for private
62-
* @param null|string $organization username of organization if applicable
58+
* @param string $name name of the repository
59+
* @param string $description repository description
60+
* @param string $homepage homepage url
61+
* @param boolean $public `true` for public, `false` for private
62+
* @param null|string $organization username of organization if applicable
63+
* @param boolean $hasIssues `true` to enable issues for this repository, `false` to disable them
64+
* @param boolean $hasWiki `true` to enable the wiki for this repository, `false` to disable it
65+
* @param boolean $hadDownloads `true` to enable downloads for this repository, `false` to disable them
66+
* @param integer $teamId The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
67+
* @param boolean $autoInit `true` to create an initial commit with empty README, `false` for no initial commit
6368
*
6469
* @return array returns repository data
6570
*/
66-
public function create($name, $description = '', $homepage = '', $public = true, $organization = null)
67-
{
71+
public function create(
72+
$name,
73+
$description = '',
74+
$homepage = '',
75+
$public = true,
76+
$organization = null,
77+
$hasIssues = false,
78+
$hasWiki = false,
79+
$hasDownloads = false,
80+
$teamId = null,
81+
$autoInit = false
82+
) {
6883
$path = null !== $organization ? 'orgs/'.$organization.'/repos' : 'user/repos';
6984

70-
return $this->post($path, array(
71-
'name' => $name,
72-
'description' => $description,
73-
'homepage' => $homepage,
74-
'private' => !$public
75-
));
85+
$parameters = array(
86+
'name' => $name,
87+
'description' => $description,
88+
'homepage' => $homepage,
89+
'private' => !$public,
90+
'has_issues' => $hasIssues,
91+
'has_wiki' => $hasWiki,
92+
'has_downloads' => $hasDownloads,
93+
'auto_init' => $autoInit
94+
);
95+
96+
if ($organization && $teamId) {
97+
$parameters['team_id'] = $teamId;
98+
}
99+
100+
return $this->post($path, $parameters);
76101
}
77102

78103
/**

0 commit comments

Comments
 (0)