Skip to content

Get-GitHubRepositoryTeamPermission incorrectly reports push permission when maintain is available #360

Closed

Description

Issue Details

When the feature was introduced in #300, an additional property called permission was added to the returned object which was supposed to summarize the maximum permission level that a team has been granted. This is what that permission table looks like:

name permissions granted
pull pull
triage pull, triage
push pull, triage, push
maintain pull, triage, push, maintain
admin pull, triage, push, maintain, admin

Unfortunately, the logic treated push as more powerful that maintain, and thus it always sets the new permission property to push for both push and maintain teams.

Steps to reproduce the issue

$repoName = [Guid]::NewGuid().Guid
$organizationName = 'PowerShellForGitHubTeamTestOrg'
$repo = New-GitHubRepository -OrganizationName $organizationName -RepositoryName $repoName
$teamName = [Guid]::NewGuid().Guid
$team = New-GitHubTeam -OrganizationName $organizationName -TeamName $teamName -Description 'foo' -Privacy 'closed' -MaintainerName 'PowerShellForGitHubTeam'

Set-GitHubRepositoryTeamPermission -Uri $repo.svn_url -TeamSlug $team.slug -Permission maintain
$permission = Get-GitHubRepositoryTeamPermission -Uri $repo.svn_url -TeamSlug $team.slug

$permission.permissions # Note here that maintain is set to true
$permission.permission # Note that it's returning push instead of maintain

This problem was originally identified by Mark (@tigerfansga) in #194

Suggested solution to the issue

Switch the order of the conditionals here:

elseif ($result.permissions.push)
{
$permission = 'push'
}
elseif ($result.permissions.maintain)
{
$permission = 'maintain'
}

Requested Assignment

- If possible, I would like to fix this.

Operating System

OsName               : Microsoft Windows 11 Pro
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22000.1.amd64fre.co_release.210604-1628
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22000.653
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.653
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module Version

Running: 0.16.1
Installed:

Activity

  1. added
    bugThis relates to a bug in the existing module.
    api-repositoriesWork to complete the API's defined here: https://developer.github.com/v3/repos/
    in progressWork on this issue is already underway. Please don't work start new work on it.
    on Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-repositoriesWork to complete the API's defined here: https://developer.github.com/v3/repos/bugThis relates to a bug in the existing module.in progressWork on this issue is already underway. Please don't work start new work on it.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions