From 3cdd4be64f6f649b4c99e79790dd00dfc8a8057d Mon Sep 17 00:00:00 2001 From: mruell <46520365+mruell@users.noreply.github.com> Date: Sun, 12 Jun 2022 19:37:04 +0200 Subject: [PATCH] feature #1062 Fix issue https://github.com/KnpLabs/php-github-api/issues/1061 (mruell) This PR was squashed before being merged into the 3.4.x-dev branch. Discussion ---------- Commits ------- bc93867eed5815ab9567f8e01f240a3b3f6b7b47 Boolean private needed to create private repo as seen in: https://docs.github.com/en/rest/reference/repos#create-an-organization-repository a1f96868c572d01a99eeca93d21b56a24b90f09d Fix tests 74a46eeb9002dcd2b3a340ef5004b179b3bc9fdb Merge branch 'KnpLabs:master' into master 11d92e73ab2d63e54410640fbf0d6cdbe292dcf5 Fix issue d2780b50b0169c540ad5edee1b2c60a9831a01a9 Fix tests --- lib/Github/Api/Repo.php | 5 ++++- test/Github/Tests/Api/RepoTest.php | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index 12fe726b450..5760a587bed 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -206,7 +206,6 @@ public function create( 'description' => $description, 'homepage' => $homepage, 'private' => ($visibility ?? ($public ? 'public' : 'private')) === 'private', - 'visibility' => $visibility ?? ($public ? 'public' : 'private'), 'has_issues' => $hasIssues, 'has_wiki' => $hasWiki, 'has_downloads' => $hasDownloads, @@ -214,6 +213,10 @@ public function create( 'has_projects' => $hasProjects, ]; + if ($visibility) { + $parameters['visibility'] = $visibility; + } + if ($organization && $teamId) { $parameters['team_id'] = $teamId; } diff --git a/test/Github/Tests/Api/RepoTest.php b/test/Github/Tests/Api/RepoTest.php index 7ba181dd53f..9cfa7f84a88 100644 --- a/test/Github/Tests/Api/RepoTest.php +++ b/test/Github/Tests/Api/RepoTest.php @@ -95,7 +95,6 @@ public function shouldCreateRepositoryUsingNameOnly() 'name' => 'l3l0Repo', 'description' => '', 'homepage' => '', - 'visibility' => 'public', 'private' => false, 'has_issues' => false, 'has_wiki' => false, @@ -122,7 +121,6 @@ public function shouldCreateRepositoryForOrganization() 'name' => 'KnpLabsRepo', 'description' => '', 'homepage' => '', - 'visibility' => 'public', 'private' => false, 'has_issues' => false, 'has_wiki' => false, @@ -374,7 +372,6 @@ public function shouldCreateUsingAllParams() 'name' => 'l3l0Repo', 'description' => 'test', 'homepage' => 'http://l3l0.eu', - 'visibility' => 'private', 'private' => true, 'has_issues' => false, 'has_wiki' => false,