Skip to content

Commit

Permalink
Replace deprecated organization team repository add/remove urls
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Mar 28, 2021
1 parent d343143 commit dfe1bc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/Github/Api/Organization/Teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ public function repository($team, $organization, $repository)

public function addRepository($team, $organization, $repository, $params = [])
{
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) {
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin', 'maintain', 'triage'])) {
$params['permission'] = 'pull';
}

return $this->put('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params);
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params);
}

public function removeRepository($team, $organization, $repository)
{
return $this->delete('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository));
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository));
}
}
4 changes: 2 additions & 2 deletions test/Github/Tests/Api/Organization/TeamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function shouldAddTeamRepository()
$api = $this->getApiMock();
$api->expects($this->once())
->method('put')
->with('/teams/KnpWorld/repos/l3l0/l3l0Repo')
->with('/orgs/l3l0/teams/KnpWorld/repos/KnpWorld/l3l0Repo')
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->addRepository('KnpWorld', 'l3l0', 'l3l0Repo'));
Expand All @@ -177,7 +177,7 @@ public function shouldRemoveTeamRepository()
$api = $this->getApiMock();
$api->expects($this->once())
->method('delete')
->with('/teams/KnpWorld/repos/l3l0/l3l0Repo')
->with('/orgs/l3l0/teams/KnpWorld/repos/KnpWorld/l3l0Repo')
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->removeRepository('KnpWorld', 'l3l0', 'l3l0Repo'));
Expand Down

0 comments on commit dfe1bc1

Please sign in to comment.