diff --git a/public/addRepoIssueComment.ps1 b/public/addRepoIssueComment.ps1 index f1571b7..a8e23a2 100644 --- a/public/addRepoIssueComment.ps1 +++ b/public/addRepoIssueComment.ps1 @@ -63,7 +63,7 @@ function Get-RepoIssue{ return $null } - $param = @{ owner = $Owner ; repo = $Repo; attributes="number,title,url" } + $param = @{ owner = $Owner ; repo = $Repo; attributes="number,title,state,url" } # Return the URL of the comment $result = Invoke-MyCommandJson -Command ListRepoIssues -Parameters $param diff --git a/public/getRepoAccess.ps1 b/public/getRepoAccess.ps1 index 44fe3fe..2a52626 100644 --- a/public/getRepoAccess.ps1 +++ b/public/getRepoAccess.ps1 @@ -10,7 +10,8 @@ function Get-RepoAccess{ [OutputType([hashtable])] param( [Parameter()] [string]$Owner, - [Parameter()] [string]$Repo + [Parameter()] [string]$Repo, + [Parameter()] [string]$Role ) # Resolve repo name from parameters or environment @@ -33,6 +34,11 @@ function Get-RepoAccess{ # no need to unique the list as github makes them exclusive $ret = $access + $invitations + if($Role){ + "Filtering by role: $Role" | Write-Verbose + $ret = $ret.GetEnumerator() | Where-Object { $_.Value -like "$Role*" } + } + "Found $($ret.Count) users with access or invitations" | Write-Verbose return $ret diff --git a/public/getRepoAccessTeam.ps1 b/public/getRepoAccessTeam.ps1 index 1befa88..e5eb16c 100644 --- a/public/getRepoAccessTeam.ps1 +++ b/public/getRepoAccessTeam.ps1 @@ -33,13 +33,9 @@ function Get-RepoAccessTeam{ } # Get access Control - $accessList = Get-RepoAccess -Owner $owner -Repo $repo - - if($Role){ - "Filtering by role: $Role" | Write-Verbose - $accessList = $accessList.GetEnumerator() | Where-Object { $_.Value -like "$Role*" } - } + $accessList = Get-RepoAccess -Owner $owner -Repo $repo -Role:$Role + # Sort by access $accessList = $accessList.GetEnumerator() | Sort-Object -Property Value @@ -109,13 +105,13 @@ function Get-RepoUser{ ) process{ - - $parameters = @{ - login = $Login - } - $result = Invoke-MyCommandJson -Command GetUser -Parameters $parameters + $result = Get-UserInfo -Login $Login + if($null -eq $result){ + "Error: $Login not found" | Write-Error + return + } $ret = [PSCustomObject]@{ login = $result.login name = $result.name @@ -131,3 +127,22 @@ function Get-RepoUser{ } } Export-ModuleMember -Function Get-RepoUser +function Get-UserInfo{ + [CmdletBinding()] + [OutputType([PSCustomObject])] + param( + [Parameter(Position=0,ValueFromPipeline)][string]$Login + ) + + process{ + $user = Invoke-MyCommandJson -Command GetUser -Parameters @{login = $Login} + + if($user.login -ne $Login){ + "Error: $login not found" | Write-Error + return $null + } + + return $user + } +} Export-ModuleMember -Function Get-UserInfo + diff --git a/public/hashtable.ps1 b/public/hashtable.ps1 new file mode 100644 index 0000000..bbe6413 --- /dev/null +++ b/public/hashtable.ps1 @@ -0,0 +1,11 @@ +function Convert-HashtableToObject { + param ( + [hashtable]$Hashtable + ) + $Hashtable.GetEnumerator() | ForEach-Object { + [PSCustomObject]@{ + Handle=$_.Key + Role=$_.Value + } + } +} Export-ModuleMember -Function Convert-HashtableToObject \ No newline at end of file