@@ -658,8 +658,10 @@ filter Get-GitHubRepository
658658 SupportsShouldProcess ,
659659 DefaultParameterSetName = ' AuthenticatedUser' )]
660660 [OutputType ({$script :GitHubRepositoryTypeName })]
661- [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSShouldProcess" , " " , Justification= " Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently." )]
662- [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSReviewUnusedParameter" , " " , Justification= " One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1." )]
661+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSShouldProcess" , " " ,
662+ Justification= " Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently." )]
663+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSReviewUnusedParameter" , " " ,
664+ Justification= " One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1." )]
663665 param (
664666 [Parameter (
665667 ValueFromPipelineByPropertyName ,
@@ -687,6 +689,7 @@ filter Get-GitHubRepository
687689 [string ] $Visibility ,
688690
689691 [Parameter (ParameterSetName = ' AuthenticatedUser' )]
692+ [ValidateSet (' Owner' , ' Collaborator' , ' OrganizationMember' )]
690693 [string []] $Affiliation ,
691694
692695 [Parameter (ParameterSetName = ' AuthenticatedUser' )]
@@ -736,11 +739,11 @@ filter Get-GitHubRepository
736739 $description = [String ]::Empty
737740 switch ($PSCmdlet.ParameterSetName )
738741 {
739- { ( ' ElementsOrUser' , ' Uri ' ) -contains $_ } {
742+ ' ElementsOrUser' {
740743 # This is a little tricky. Ideally we'd have two separate ParameterSets (Elements, User),
741744 # however PowerShell would be unable to disambiguate between the two, so unfortunately
742745 # we need to do some additional work here. And because fallthru doesn't appear to be
743- # working right, we're combining both of those, along with Uri .
746+ # working right, we're combining both of those.
744747
745748 if ([String ]::IsNullOrWhiteSpace($OwnerName ))
746749 {
@@ -750,37 +753,24 @@ filter Get-GitHubRepository
750753 }
751754 elseif ([String ]::IsNullOrWhiteSpace($RepositoryName ))
752755 {
753- if ($PSCmdlet.ParameterSetName -eq ' ElementsOrUser' )
754- {
755- $telemetryProperties [' UsageType' ] = ' User'
756- $telemetryProperties [' OwnerName' ] = Get-PiiSafeString - PlainText $OwnerName
756+ $telemetryProperties [' UsageType' ] = ' User'
757+ $telemetryProperties [' OwnerName' ] = Get-PiiSafeString - PlainText $OwnerName
757758
758- $uriFragment = " users/$OwnerName /repos"
759- $description = " Getting repos for $OwnerName "
760- }
761- else
762- {
763- $message = ' RepositoryName could not be determined.'
764- Write-Log - Message $message - Level Error
765- throw $message
766- }
759+ $uriFragment = " users/$OwnerName /repos"
760+ $description = " Getting repos for $OwnerName "
767761 }
768762 else
769763 {
770- if ($PSCmdlet.ParameterSetName -eq ' ElementsOrUser' )
764+ if ($PSBoundParameters.ContainsKey (' Type' ) -or
765+ $PSBoundParameters.ContainsKey (' Sort' ) -or
766+ $PSBoundParameters.ContainsKey (' Direction' ))
771767 {
772- $telemetryProperties [' UsageType' ] = ' Elements'
773-
774- if ($PSBoundParameters.ContainsKey (' Type' ) -or
775- $PSBoundParameters.ContainsKey (' Sort' ) -or
776- $PSBoundParameters.ContainsKey (' Direction' ))
777- {
778- $message = ' Unable to specify -Type, -Sort and/or -Direction when retrieving a specific repository.'
779- Write-Log - Message $message - Level Error
780- throw $message
781- }
768+ $message = ' Unable to specify -Type, -Sort and/or -Direction when retrieving a specific repository.'
769+ Write-Log - Message $message - Level Error
770+ throw $message
782771 }
783772
773+ $telemetryProperties [' UsageType' ] = ' Elements'
784774 $telemetryProperties [' OwnerName' ] = Get-PiiSafeString - PlainText $OwnerName
785775 $telemetryProperties [' RepositoryName' ] = Get-PiiSafeString - PlainText $RepositoryName
786776
@@ -791,20 +781,30 @@ filter Get-GitHubRepository
791781 break
792782 }
793783
794- ' Organization' {
795- $telemetryProperties [' OrganizationName' ] = Get-PiiSafeString - PlainText $OrganizationName
784+ ' Uri' {
785+ if ($PSBoundParameters.ContainsKey (' Type' ) -or
786+ $PSBoundParameters.ContainsKey (' Sort' ) -or
787+ $PSBoundParameters.ContainsKey (' Direction' ))
788+ {
789+ $message = ' Unable to specify -Type, -Sort and/or -Direction when retrieving a specific repository.'
790+ Write-Log - Message $message - Level Error
791+ throw $message
792+ }
796793
797- $uriFragment = " orgs/$OrganizationName /repos"
798- $description = " Getting repos for $OrganizationName "
794+ $telemetryProperties [' OwnerName' ] = Get-PiiSafeString - PlainText $OwnerName
795+ $telemetryProperties [' RepositoryName' ] = Get-PiiSafeString - PlainText $RepositoryName
796+
797+ $uriFragment = " repos/$OwnerName /$RepositoryName "
798+ $description = " Getting $OwnerName /$RepositoryName "
799799
800800 break
801801 }
802802
803- ' User ' {
804- $telemetryProperties [' OwnerName ' ] = Get-PiiSafeString - PlainText $OwnerName
803+ ' Organization ' {
804+ $telemetryProperties [' OrganizationName ' ] = Get-PiiSafeString - PlainText $OrganizationName
805805
806- $uriFragment = " users/ $OwnerName /repos"
807- $description = " Getting repos for $OwnerName "
806+ $uriFragment = " orgs/ $OrganizationName /repos"
807+ $description = " Getting repos for $OrganizationName "
808808
809809 break
810810 }
@@ -857,7 +857,18 @@ filter Get-GitHubRepository
857857 if ($PSBoundParameters.ContainsKey (' Direction' )) { $getParams += " direction=$ ( $directionConverter [$Direction ]) " }
858858 if ($PSBoundParameters.ContainsKey (' Affiliation' ) -and $Affiliation.Count -gt 0 )
859859 {
860- $getParams += " affiliation=$ ( $Affiliation -join ' ,' ) "
860+ $affiliationMap = @ {
861+ Owner = ' owner'
862+ Collaborator = ' collaborator'
863+ OrganizationMember = ' organization_member'
864+ }
865+ $affiliationParam = @ ()
866+
867+ foreach ($member in $Affiliation )
868+ {
869+ $affiliationParam += $affiliationMap [$member ]
870+ }
871+ $getParams += " affiliation=$ ( $affiliationParam -join ' ,' ) "
861872 }
862873 if ($PSBoundParameters.ContainsKey (' Since' )) { $getParams += " since=$Since " }
863874
@@ -1602,8 +1613,12 @@ filter Get-GitHubRepositoryContributor
16021613 . EXAMPLE
16031614 Get-GitHubRepositoryContributor -OwnerName microsoft -RepositoryName PowerShellForGitHub
16041615
1616+ Gets a list of contributors for the PowerShellForGithub repository.
1617+
16051618 . EXAMPLE
16061619 Get-GitHubRepositoryContributor -Uri 'https://github.com/PowerShell/PowerShellForGitHub' -IncludeStatistics
1620+
1621+ Gets a list of contributors for the PowerShellForGithub repository including statistics.
16071622#>
16081623 [CmdletBinding (
16091624 SupportsShouldProcess ,
@@ -1691,10 +1706,10 @@ filter Get-GitHubRepositoryCollaborator
16911706{
16921707<#
16931708 . SYNOPSIS
1694- Retrieve list of contributors for a given repository.
1709+ Retrieve list of collaborators for a given repository.
16951710
16961711 . DESCRIPTION
1697- Retrieve list of contributors for a given repository.
1712+ Retrieve list of collaborators for a given repository.
16981713
16991714 The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
17001715
@@ -1749,8 +1764,12 @@ filter Get-GitHubRepositoryCollaborator
17491764 . EXAMPLE
17501765 Get-GitHubRepositoryCollaborator -OwnerName microsoft -RepositoryName PowerShellForGitHub
17511766
1767+ Gets a list of collaborators for the PowerShellForGithub repository.
1768+
17521769 . EXAMPLE
17531770 Get-GitHubRepositoryCollaborator -Uri 'https://github.com/PowerShell/PowerShellForGitHub'
1771+
1772+ Gets a list of collaborators for the PowerShellForGithub repository.
17541773#>
17551774 [CmdletBinding (
17561775 SupportsShouldProcess ,
@@ -2027,10 +2046,10 @@ filter Move-GitHubRepositoryOwnership
20272046{
20282047<#
20292048 . SYNOPSIS
2030- Creates a new repository on GitHub.
2049+ Changes the ownership of a repository on GitHub.
20312050
20322051 . DESCRIPTION
2033- Creates a new repository on GitHub.
2052+ Changes the ownership of a repository on GitHub.
20342053
20352054 The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
20362055
0 commit comments