Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 189
Update GitHubRepositories Tests and Refactor Get-GitHubRepository Function#233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Howard Wolosky (HowardWolosky)
merged 10 commits into
microsoft:master
from
X-Guardian:GitHubRepositories-Test-AdditionsJun 28, 2020
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8a3162a
update GitHubRepositories tests
X-Guardian 9372e07
Update GitHubRepositories
X-Guardian efb0f7a
Split long SuppressMessageAttribute lines
X-Guardian 04a5faa
Update Affiliation parameter
X-Guardian 6c92a18
Update Get-GitHubRepository tests
X-Guardian 47ccccc
Test updates after pipeline changes
X-Guardian a301c9c
Fix review comments
X-Guardian 363aa96
Fix review comments
X-Guardian e7a1d8e
Fix review comments
X-Guardian 2ab18e9
Update tests
X-Guardian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -658,8 +658,10 @@ filter Get-GitHubRepository | ||
| SupportsShouldProcess, | ||
| DefaultParameterSetName='AuthenticatedUser')] | ||
| [OutputType({$script:GitHubRepositoryTypeName})] | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] | ||
| [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.")] | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", | ||
| Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] | ||
| [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.")] | ||
| param( | ||
| [Parameter( | ||
| ValueFromPipelineByPropertyName, | ||
| @@ -687,6 +689,7 @@ filter Get-GitHubRepository | ||
| [string] $Visibility, | ||
| [Parameter(ParameterSetName='AuthenticatedUser')] | ||
| [ValidateSet('Owner', 'Collaborator', 'OrganizationMember')] | ||
| [string[]] $Affiliation, | ||
| [Parameter(ParameterSetName='AuthenticatedUser')] | ||
| @@ -736,11 +739,11 @@ filter Get-GitHubRepository | ||
| $description = [String]::Empty | ||
| switch ($PSCmdlet.ParameterSetName) | ||
| { | ||
| { ('ElementsOrUser', 'Uri') -contains $_ } { | ||
| 'ElementsOrUser' { | ||
| # This is a little tricky. Ideally we'd have two separate ParameterSets (Elements, User), | ||
| # however PowerShell would be unable to disambiguate between the two, so unfortunately | ||
| # we need to do some additional work here. And because fallthru doesn't appear to be | ||
| # working right, we're combining both of those, along with Uri. | ||
| # working right, we're combining both of those. | ||
| if ([String]::IsNullOrWhiteSpace($OwnerName)) | ||
| { | ||
| @@ -750,37 +753,24 @@ filter Get-GitHubRepository | ||
| } | ||
| elseif ([String]::IsNullOrWhiteSpace($RepositoryName)) | ||
| { | ||
| if ($PSCmdlet.ParameterSetName -eq 'ElementsOrUser') | ||
| { | ||
| $telemetryProperties['UsageType'] = 'User' | ||
| $telemetryProperties['OwnerName'] = Get-PiiSafeString -PlainText $OwnerName | ||
| $telemetryProperties['UsageType'] = 'User' | ||
| $telemetryProperties['OwnerName'] = Get-PiiSafeString -PlainText $OwnerName | ||
| $uriFragment = "users/$OwnerName/repos" | ||
| $description = "Getting repos for $OwnerName" | ||
| } | ||
| else | ||
| { | ||
| $message = 'RepositoryName could not be determined.' | ||
| Write-Log -Message $message -Level Error | ||
| throw $message | ||
| } | ||
| $uriFragment = "users/$OwnerName/repos" | ||
| $description = "Getting repos for $OwnerName" | ||
| } | ||
| else | ||
| { | ||
| if ($PSCmdlet.ParameterSetName -eq 'ElementsOrUser') | ||
| if ($PSBoundParameters.ContainsKey('Type') -or | ||
X-Guardian marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $PSBoundParameters.ContainsKey('Sort') -or | ||
| $PSBoundParameters.ContainsKey('Direction')) | ||
| { | ||
| $telemetryProperties['UsageType'] = 'Elements' | ||
| if ($PSBoundParameters.ContainsKey('Type') -or | ||
| $PSBoundParameters.ContainsKey('Sort') -or | ||
| $PSBoundParameters.ContainsKey('Direction')) | ||
| { | ||
| $message = 'Unable to specify -Type, -Sort and/or -Direction when retrieving a specific repository.' | ||
| Write-Log -Message $message -Level Error | ||
| throw $message | ||
| } | ||
| $message = 'Unable to specify -Type, -Sort and/or -Direction when retrieving a specific repository.' | ||
| Write-Log -Message $message -Level Error | ||
| throw $message | ||
| } | ||
| $telemetryProperties['UsageType'] = 'Elements' | ||
| $telemetryProperties['OwnerName'] = Get-PiiSafeString -PlainText $OwnerName | ||
| $telemetryProperties['RepositoryName'] = Get-PiiSafeString -PlainText $RepositoryName | ||
| @@ -791,20 +781,30 @@ filter Get-GitHubRepository | ||
| break | ||
| } | ||
| 'Organization' { | ||
| $telemetryProperties['OrganizationName'] = Get-PiiSafeString -PlainText $OrganizationName | ||
| 'Uri' { | ||
| if ($PSBoundParameters.ContainsKey('Type') -or | ||
| $PSBoundParameters.ContainsKey('Sort') -or | ||
| $PSBoundParameters.ContainsKey('Direction')) | ||
| { | ||
| $message = 'Unable to specify -Type, -Sort and/or -Direction when retrieving a specific repository.' | ||
| Write-Log -Message $message -Level Error | ||
| throw $message | ||
| } | ||
| $uriFragment = "orgs/$OrganizationName/repos" | ||
| $description = "Getting repos for $OrganizationName" | ||
| $telemetryProperties['OwnerName'] = Get-PiiSafeString -PlainText $OwnerName | ||
| $telemetryProperties['RepositoryName'] = Get-PiiSafeString -PlainText $RepositoryName | ||
| $uriFragment = "repos/$OwnerName/$RepositoryName" | ||
| $description = "Getting $OwnerName/$RepositoryName" | ||
| break | ||
| } | ||
| 'User' { | ||
| $telemetryProperties['OwnerName'] = Get-PiiSafeString -PlainText $OwnerName | ||
| 'Organization' { | ||
| $telemetryProperties['OrganizationName'] = Get-PiiSafeString -PlainText $OrganizationName | ||
| $uriFragment = "users/$OwnerName/repos" | ||
| $description = "Getting repos for $OwnerName" | ||
| $uriFragment = "orgs/$OrganizationName/repos" | ||
| $description = "Getting repos for $OrganizationName" | ||
| break | ||
| } | ||
| @@ -857,7 +857,18 @@ filter Get-GitHubRepository | ||
| if ($PSBoundParameters.ContainsKey('Direction')) { $getParams += "direction=$($directionConverter[$Direction])" } | ||
| if ($PSBoundParameters.ContainsKey('Affiliation') -and $Affiliation.Count -gt 0) | ||
| { | ||
| $getParams += "affiliation=$($Affiliation -join ',')" | ||
| $affiliationMap = @{ | ||
| Owner = 'owner' | ||
| Collaborator = 'collaborator' | ||
| OrganizationMember = 'organization_member' | ||
| } | ||
| $affiliationParam = @() | ||
| foreach ($member in $Affiliation) | ||
| { | ||
| $affiliationParam += $affiliationMap[$member] | ||
| } | ||
| $getParams += "affiliation=$($affiliationParam -join ',')" | ||
| } | ||
| if ($PSBoundParameters.ContainsKey('Since')) { $getParams += "since=$Since" } | ||
| @@ -1602,8 +1613,12 @@ filter Get-GitHubRepositoryContributor | ||
| .EXAMPLE | ||
| Get-GitHubRepositoryContributor -OwnerName microsoft -RepositoryName PowerShellForGitHub | ||
| Gets a list of contributors for the PowerShellForGithub repository. | ||
| .EXAMPLE | ||
| Get-GitHubRepositoryContributor -Uri 'https://github.com/PowerShell/PowerShellForGitHub' -IncludeStatistics | ||
| Gets a list of contributors for the PowerShellForGithub repository including statistics. | ||
| #> | ||
| [CmdletBinding( | ||
| SupportsShouldProcess, | ||
| @@ -1691,10 +1706,10 @@ filter Get-GitHubRepositoryCollaborator | ||
| { | ||
| <# | ||
| .SYNOPSIS | ||
| Retrieve list of contributors for a given repository. | ||
| Retrieve list of collaborators for a given repository. | ||
| .DESCRIPTION | ||
| Retrieve list of contributors for a given repository. | ||
| Retrieve list of collaborators for a given repository. | ||
| The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub | ||
| @@ -1749,8 +1764,12 @@ filter Get-GitHubRepositoryCollaborator | ||
| .EXAMPLE | ||
| Get-GitHubRepositoryCollaborator -OwnerName microsoft -RepositoryName PowerShellForGitHub | ||
| Gets a list of collaborators for the PowerShellForGithub repository. | ||
| .EXAMPLE | ||
| Get-GitHubRepositoryCollaborator -Uri 'https://github.com/PowerShell/PowerShellForGitHub' | ||
| Gets a list of collaborators for the PowerShellForGithub repository. | ||
| #> | ||
| [CmdletBinding( | ||
| SupportsShouldProcess, | ||
| @@ -2027,10 +2046,10 @@ filter Move-GitHubRepositoryOwnership | ||
| { | ||
| <# | ||
| .SYNOPSIS | ||
| Creates a new repository on GitHub. | ||
| Changes the ownership of a repository on GitHub. | ||
| .DESCRIPTION | ||
| Creates a new repository on GitHub. | ||
| Changes the ownership of a repository on GitHub. | ||
| The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.