diff --git a/GitHubAssignees.ps1 b/GitHubAssignees.ps1 index 2c439da1..0964573a 100644 --- a/GitHubAssignees.ps1 +++ b/GitHubAssignees.ps1 @@ -247,7 +247,7 @@ filter Test-GitHubAssignee } } -function New-GitHubAssignee +function Add-GitHubAssignee { <# .DESCRIPTION @@ -308,7 +308,7 @@ function New-GitHubAssignee .EXAMPLE $assignees = @('octocat') - New-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1 -Assignee $assignee + Add-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1 -Assignee $assignee Additionally assigns the usernames in $assignee to Issue #1 from the microsoft\PowerShellForGitHub project. @@ -316,7 +316,7 @@ function New-GitHubAssignee .EXAMPLE $assignees = @('octocat') $repo = Get-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub - $repo | New-GitHubAssignee -Issue 1 -Assignee $assignee + $repo | Add-GitHubAssignee -Issue 1 -Assignee $assignee Additionally assigns the usernames in $assignee to Issue #1 from the microsoft\PowerShellForGitHub project. @@ -325,14 +325,14 @@ function New-GitHubAssignee $assignees = @('octocat') Get-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub | Get-GitHubIssue -Issue 1 | - New-GitHubAssignee -Assignee $assignee + Add-GitHubAssignee -Assignee $assignee Additionally assigns the usernames in $assignee to Issue #1 from the microsoft\PowerShellForGitHub project. .EXAMPLE $octocat = Get-GitHubUser -UserName 'octocat' - $octocat | New-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1 + $octocat | Add-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1 Additionally assigns the user 'octocat' to Issue #1 from the microsoft\PowerShellForGitHub project. @@ -341,6 +341,7 @@ function New-GitHubAssignee SupportsShouldProcess, DefaultParameterSetName='Elements')] [OutputType({$script:GitHubIssueTypeName})] + [Alias('New-GitHubAssignee')] # Non-standard usage of the New verb, but done to avoid a breaking change post 0.14.0 [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( diff --git a/GitHubIssues.ps1 b/GitHubIssues.ps1 index 46931a43..1010b19a 100644 --- a/GitHubIssues.ps1 +++ b/GitHubIssues.ps1 @@ -654,14 +654,14 @@ filter New-GitHubIssue return (Invoke-GHRestMethod @params | Add-GitHubIssueAdditionalProperties) } -filter Update-GitHubIssue +filter Set-GitHubIssue { <# .SYNOPSIS - Create a new Issue on GitHub. + Updates an Issue on GitHub. .DESCRIPTION - Create a new Issue on GitHub. + Updates an Issue on GitHub. The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub @@ -744,12 +744,13 @@ filter Update-GitHubIssue GitHub.Issue .EXAMPLE - Update-GitHubIssue -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -State Closed + Set-GitHubIssue -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -State Closed #> [CmdletBinding( SupportsShouldProcess, DefaultParameterSetName='Elements')] [OutputType({$script:GitHubIssueTypeName})] + [Alias('Update-GitHubIssue')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0 [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] param( [Parameter(ParameterSetName='Elements')] diff --git a/GitHubLabels.ps1 b/GitHubLabels.ps1 index 41d306f5..80f55480 100644 --- a/GitHubLabels.ps1 +++ b/GitHubLabels.ps1 @@ -486,7 +486,7 @@ filter Remove-GitHubLabel } } -filter Update-GitHubLabel +filter Set-GitHubLabel { <# .SYNOPSIS @@ -555,7 +555,7 @@ filter Update-GitHubLabel GitHub.Label .EXAMPLE - Update-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label TestLabel -NewName NewTestLabel -Color BBBB00 + Set-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label TestLabel -NewName NewTestLabel -Color BBBB00 Updates the existing label called TestLabel in the PowerShellForGitHub project to be called 'NewTestLabel' and be colored yellow. @@ -564,6 +564,7 @@ filter Update-GitHubLabel SupportsShouldProcess, DefaultParameterSetName='Elements')] [OutputType({$script:GitHubLabelTypeName})] + [Alias('Update-GitHubLabel')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0 [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] param( [Parameter(ParameterSetName='Elements')] @@ -637,15 +638,15 @@ filter Update-GitHubLabel return (Invoke-GHRestMethod @params | Add-GitHubLabelAdditionalProperties) } -filter Set-GitHubLabel +filter Initialize-GitHubLabel { <# .SYNOPSIS - Sets the entire set of Labels on the given GitHub repository to match the provided list + Replaces the entire set of Labels on the given GitHub repository to match the provided list of Labels. .DESCRIPTION - Sets the entire set of Labels on the given GitHub repository to match the provided list + Replaces the entire set of Labels on the given GitHub repository to match the provided list of Labels. Will update the color/description for any Labels already in the repository that match the @@ -697,7 +698,7 @@ filter Set-GitHubLabel GitHub.Repository .EXAMPLE - Set-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label @(@{'name' = 'TestLabel'; 'color' = 'EEEEEE'}, @{'name' = 'critical'; 'color' = 'FF000000'; 'description' = 'Needs immediate attention'}) + Initialize-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label @(@{'name' = 'TestLabel'; 'color' = 'EEEEEE'}, @{'name' = 'critical'; 'color' = 'FF000000'; 'description' = 'Needs immediate attention'}) Removes any labels not in this Label array, ensure the current assigned color and descriptions match what's in the array for the labels that do already exist, and then creates new labels @@ -769,7 +770,7 @@ filter Set-GitHubLabel else { # Update label's color if it already exists - $null = Update-GitHubLabel -Label $labelToConfigure.name -NewName $labelToConfigure.name -Color $labelToConfigure.color @commonParams + $null = Set-GitHubLabel -Label $labelToConfigure.name -NewName $labelToConfigure.name -Color $labelToConfigure.color @commonParams } } diff --git a/GitHubRepositories.ps1 b/GitHubRepositories.ps1 index 7a2c2e04..8bc58389 100644 --- a/GitHubRepositories.ps1 +++ b/GitHubRepositories.ps1 @@ -1015,11 +1015,11 @@ filter Rename-GitHubRepository ) # This method was created by mistake and is now retained to avoid a breaking change. - # Update-GitHubRepository is able to handle this scenario just fine. - return Update-GitHubRepository @PSBoundParameters + # Set-GitHubRepository is able to handle this scenario just fine. + return Set-GitHubRepository @PSBoundParameters } -filter Update-GitHubRepository +filter Set-GitHubRepository { <# .SYNOPSIS @@ -1125,18 +1125,18 @@ filter Update-GitHubRepository GitHub.Repository .EXAMPLE - Update-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub -Description 'The best way to automate your GitHub interactions' + Set-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub -Description 'The best way to automate your GitHub interactions' Changes the description of the specified repository. .EXAMPLE - Update-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub -Private:$false + Set-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub -Private:$false Changes the visibility of the specified repository to be public. .EXAMPLE Get-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub | - Update-GitHubRepository -NewName 'PoShForGitHub' -Force + Set-GitHubRepository -NewName 'PoShForGitHub' -Force Renames the repository without any user confirmation prompting. This is identical to using Rename-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub -NewName 'PoShForGitHub' -Confirm:$false @@ -1146,6 +1146,7 @@ filter Update-GitHubRepository DefaultParameterSetName='Elements', ConfirmImpact='High')] [OutputType({$script:GitHubRepositoryTypeName})] + [Alias('Update-GitHubRepository')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0 [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] param( [Parameter(ParameterSetName='Elements')] diff --git a/GitHubUsers.ps1 b/GitHubUsers.ps1 index 1ed37ccc..16019b45 100644 --- a/GitHubUsers.ps1 +++ b/GitHubUsers.ps1 @@ -300,14 +300,14 @@ filter Get-GitHubUserContextualInformation return $result } -function Update-GitHubCurrentUser +function Set-GitHubProfile { <# .SYNOPSIS - Updates information about the current authenticated user on GitHub. + Updates profile information for the current authenticated user on GitHub. .DESCRIPTION - Updates information about the current authenticated user on GitHub. + Updates profile information for the current authenticated user on GitHub. The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub @@ -347,13 +347,14 @@ function Update-GitHubCurrentUser GitHub.User .EXAMPLE - Update-GitHubCurrentUser -Location 'Seattle, WA' -Hireable:$false + Set-GitHubProfile -Location 'Seattle, WA' -Hireable:$false Updates the current user to indicate that their location is "Seattle, WA" and that they are not currently hireable. #> [CmdletBinding(SupportsShouldProcess)] [OutputType({$script:GitHubUserTypeName})] + [Alias('Update-GitHubCurrentUser')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0 [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] param( [string] $Name, diff --git a/PowerShellForGitHub.psd1 b/PowerShellForGitHub.psd1 index b49ff1f0..cb7fcf06 100644 --- a/PowerShellForGitHub.psd1 +++ b/PowerShellForGitHub.psd1 @@ -55,6 +55,7 @@ # Functions to export from this module FunctionsToExport = @( + 'Add-GitHubAssignee', 'Add-GitHubIssueLabel', 'Backup-GitHubConfiguration', 'Clear-GitHubAuthentication', @@ -102,6 +103,7 @@ 'Get-GitHubViewTraffic', 'Group-GitHubIssue', 'Group-GitHubPullRequest', + 'Initialize-GitHubLabel', 'Invoke-GHRestMethod', 'Invoke-GHRestMethodMultipleResult', 'Join-GitHubUri', @@ -109,7 +111,6 @@ 'Move-GitHubProjectCard', 'Move-GitHubProjectColumn', 'Move-GitHubRepositoryOwnership', - 'New-GitHubAssignee', 'New-GitHubIssue', 'New-GitHubIssueComment', 'New-GitHubLabel', @@ -136,24 +137,23 @@ 'Set-GitHubAuthentication', 'Set-GitHubConfiguration', 'Set-GitHubContent', + 'Set-GitHubIssue', 'Set-GitHubIssueComment', 'Set-GitHubIssueLabel', 'Set-GitHubLabel', 'Set-GitHubMilestone', + 'Set-GitHubProfile', 'Set-GitHubProject', 'Set-GitHubProjectCard', 'Set-GitHubProjectColumn', + 'Set-GitHubRepository' 'Set-GitHubRepositoryTopic', 'Split-GitHubUri', 'Test-GitHubAssignee', 'Test-GitHubAuthenticationConfigured', 'Test-GitHubOrganizationMember', 'Test-GitHubRepositoryVulnerabilityAlert', - 'Unlock-GitHubIssue', - 'Update-GitHubCurrentUser', - 'Update-GitHubIssue', - 'Update-GitHubLabel', - 'Update-GitHubRepository' + 'Unlock-GitHubIssue' ) AliasesToExport = @( @@ -167,10 +167,15 @@ 'Delete-GitHubRepository', 'Get-GitHubBranch', 'Get-GitHubComment', + 'New-GitHubAssignee', 'New-GitHubComment', 'Remove-GitHubComment', 'Set-GitHubComment', 'Transfer-GitHubRepositoryOwnership' + 'Update-GitHubIssue', + 'Update-GitHubLabel', + 'Update-GitHubCurrentUser', + 'Update-GitHubRepository' ) # Cmdlets to export from this module diff --git a/Tests/GitHubAssignees.tests.ps1 b/Tests/GitHubAssignees.tests.ps1 index d9eeb61c..64a694b5 100644 --- a/Tests/GitHubAssignees.tests.ps1 +++ b/Tests/GitHubAssignees.tests.ps1 @@ -112,7 +112,7 @@ try $issue.assignees | Should -BeNullOrEmpty } - $updatedIssue = New-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number -Assignee $owner.login + $updatedIssue = Add-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number -Assignee $owner.login It 'Should have returned the same issue' { $updatedIssue.number | Should -Be $issue.number } @@ -149,7 +149,7 @@ try $issue.assignees | Should -BeNullOrEmpty } - $updatedIssue = $repo | New-GitHubAssignee -Issue $issue.number -Assignee $owner.login + $updatedIssue = $repo | Add-GitHubAssignee -Issue $issue.number -Assignee $owner.login It 'Should have returned the same issue' { $updatedIssue.number | Should -Be $issue.number } @@ -186,7 +186,7 @@ try $issue.assignees | Should -BeNullOrEmpty } - $updatedIssue = $issue | New-GitHubAssignee -Assignee $owner.login + $updatedIssue = $issue | Add-GitHubAssignee -Assignee $owner.login It 'Should have returned the same issue' { $updatedIssue.number | Should -Be $issue.number } @@ -223,7 +223,7 @@ try $issue.assignees | Should -BeNullOrEmpty } - $updatedIssue = $owner | New-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number + $updatedIssue = $owner | Add-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number It 'Should have returned the same issue' { $updatedIssue.number | Should -Be $issue.number } diff --git a/Tests/GitHubEvents.tests.ps1 b/Tests/GitHubEvents.tests.ps1 index 43390e7a..963cd9b1 100644 --- a/Tests/GitHubEvents.tests.ps1 +++ b/Tests/GitHubEvents.tests.ps1 @@ -45,7 +45,7 @@ try Context 'For getting Issue events from a repository' { $issue = $repo | New-GitHubIssue -Title 'New Issue' - $issue = $issue | Update-GitHubIssue -State Closed + $issue = $issue | Set-GitHubIssue -State Closed $events = @($repo | Get-GitHubEvent) It 'Should have an event from closing an issue' { @@ -82,8 +82,8 @@ try } Context 'For getting events from an issue' { - $issue = $issue | Update-GitHubIssue -State Closed - $issue = $issue | Update-GitHubIssue -State Open + $issue = $issue | Set-GitHubIssue -State Closed + $issue = $issue | Set-GitHubIssue -State Open $events = @(Get-GitHubEvent -OwnerName $ownerName -RepositoryName $repositoryName) It 'Should have two events from closing and opening the issue' { @@ -98,8 +98,8 @@ try $repositoryName = [Guid]::NewGuid() $repo = New-GitHubRepository -RepositoryName $repositoryName $issue = $repo | New-GitHubIssue -Title 'New Issue' - $issue = $issue | Update-GitHubIssue -State Closed - $issue = $issue | Update-GitHubIssue -State Open + $issue = $issue | Set-GitHubIssue -State Closed + $issue = $issue | Set-GitHubIssue -State Open $events = @($repo | Get-GitHubEvent) } diff --git a/Tests/GitHubIssues.tests.ps1 b/Tests/GitHubIssues.tests.ps1 index 21b4dd30..ed5c4d88 100644 --- a/Tests/GitHubIssues.tests.ps1 +++ b/Tests/GitHubIssues.tests.ps1 @@ -164,8 +164,8 @@ try Start-Sleep -Seconds 1 # Needed to ensure that there is a unique creation timestamp between issues } - $newIssues[0] = Update-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[0].number -State Closed - $newIssues[-1] = Update-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[-1].number -State Closed + $newIssues[0] = Set-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[0].number -State Closed + $newIssues[-1] = Set-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[-1].number -State Closed $existingOpenIssues = @($existingIssues | Where-Object { $_.state -eq 'open' }) $newOpenIssues = @($newIssues | Where-Object { $_.state -eq 'open' }) @@ -316,7 +316,7 @@ try 'MediaType' = 'Raw' } - $updated = Update-GitHubIssue @params + $updated = Set-GitHubIssue @params It 'Should have the expected property values' { $updated.id | Should -Be $issue.id $updated.number | Should -Be $issue.number @@ -364,7 +364,7 @@ try 'MediaType' = 'Raw' } - $updated = $repo | Update-GitHubIssue @params + $updated = $repo | Set-GitHubIssue @params It 'Should have the expected property values' { $updated.id | Should -Be $issue.id $updated.number | Should -Be $issue.number @@ -411,7 +411,7 @@ try 'MediaType' = 'Raw' } - $updated = $issue | Update-GitHubIssue @params + $updated = $issue | Set-GitHubIssue @params It 'Should have the expected property values' { $updated.id | Should -Be $issue.id $updated.number | Should -Be $issue.number diff --git a/Tests/GitHubLabels.tests.ps1 b/Tests/GitHubLabels.tests.ps1 index e2807442..5c3a1e30 100644 --- a/Tests/GitHubLabels.tests.ps1 +++ b/Tests/GitHubLabels.tests.ps1 @@ -81,7 +81,7 @@ try $repositoryName = [Guid]::NewGuid().Guid $repo = New-GitHubRepository -RepositoryName $repositoryName - Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $defaultLabels + Initialize-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $defaultLabels } AfterAll { @@ -376,7 +376,7 @@ try $label = $repo | New-GitHubLabel -Label ([Guid]::NewGuid().Guid) -Color 'BBBBBB' $newColor = 'AAAAAA' - $result = Update-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -Color $newColor + $result = Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -Color $newColor It 'Label should have different color' { $result.name | Should -Be $label.name @@ -396,7 +396,7 @@ try $label = $repo | New-GitHubLabel -Label ([Guid]::NewGuid().Guid) -Color 'BBBBBB' $newColor = '#AAAAAA' - $result = Update-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -Color $newColor + $result = Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -Color $newColor It 'Label should have different color' { $result.name | Should -Be $label.name @@ -416,7 +416,7 @@ try $label = $repo | New-GitHubLabel -Label ([Guid]::NewGuid().Guid) -Color 'BBBBBB' $newName = [Guid]::NewGuid().Guid - $result = Update-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -NewName $newName + $result = Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -NewName $newName It 'Label should have different name' { $result.name | Should -Be $newName @@ -436,7 +436,7 @@ try $label = $repo | New-GitHubLabel -Label ([Guid]::NewGuid().Guid) -Color 'BBBBBB' -Description 'test description' $newDescription = [Guid]::NewGuid().Guid - $result = Update-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -Description $newDescription + $result = Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -Description $newDescription It 'Label should have different name' { $result.name | Should -Be $label.name @@ -458,7 +458,7 @@ try $newName = [Guid]::NewGuid().Guid $newColor = 'AAAAAA' $newDescription = [Guid]::NewGuid().Guid - $result = Update-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -NewName $newName -Color $newColor -Description $newDescription + $result = Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $label.name -NewName $newName -Color $newColor -Description $newDescription It 'Label should have different everything' { $result.name | Should -Be $newName @@ -480,7 +480,7 @@ try $label = $repo | New-GitHubLabel -Label ([Guid]::NewGuid().Guid) -Color 'BBBBBB' $newColor = 'AAAAAA' - $result = $repo | Update-GitHubLabel -Label $label.name -Color $newColor + $result = $repo | Set-GitHubLabel -Label $label.name -Color $newColor It 'Label should have different color' { $result.name | Should -Be $label.name @@ -500,7 +500,7 @@ try $label = $repo | New-GitHubLabel -Label ([Guid]::NewGuid().Guid) -Color 'BBBBBB' $newName = [Guid]::NewGuid().Guid - $result = $label | Update-GitHubLabel -NewName $newName + $result = $label | Set-GitHubLabel -NewName $newName It 'Label should have different name' { $result.name | Should -Be $newName @@ -522,7 +522,7 @@ try $newName = [Guid]::NewGuid().Guid $newColor = 'AAAAAA' $newDescription = [Guid]::NewGuid().Guid - $result = $label | Update-GitHubLabel -NewName $newName -Color $newColor -Description $newDescription + $result = $label | Set-GitHubLabel -NewName $newName -Color $newColor -Description $newDescription It 'Label should have different everything' { $result.name | Should -Be $newName @@ -550,7 +550,7 @@ try } Context 'Applying a default set of labels' { - Set-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $defaultLabels + Initialize-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Label $defaultLabels $labels = @($repo | Get-GitHubLabel) @@ -578,7 +578,7 @@ try ) $originalLabels = @($repo | Get-GitHubLabel) - $null = $repo | Set-GitHubLabel -Label $newLabels + $null = $repo | Initialize-GitHubLabel -Label $newLabels $labels = @($repo | Get-GitHubLabel) It 'Should return the expected number of labels' { @@ -595,37 +595,29 @@ try } It 'Should have retained the ID''s of the pre-existing labels' { - $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[0].name } - $label = $labels | Where-Object { $_.name -eq $newLabels[0].name } - $label.id | Should -Be $originalLabel.id - - $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[1].name } - $label = $labels | Where-Object { $_.name -eq $newLabels[1].name } - $label.id | Should -Be $originalLabel.id - - $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[2].name } - $label = $labels | Where-Object { $_.name -eq $newLabels[2].name } - $label.id | Should -Be $originalLabel.id - - $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[3].name } - $label = $labels | Where-Object { $_.name -eq $newLabels[3].name } - $originalLabel | Should -BeNullOrEmpty - $label | Should -Not -BeNullOrEmpty + for ($i = 0; $i -le 2; $i++) + { + $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[$i].name } + $label = $labels | Where-Object { $_.name -eq $newLabels[$i].name } + $label.id | Should -Be $originalLabel.id + } - $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[4].name } - $label = $labels | Where-Object { $_.name -eq $newLabels[4].name } - $originalLabel | Should -BeNullOrEmpty - $label | Should -Not -BeNullOrEmpty + for ($i = 3; $i -le 4; $i++) + { + $originalLabel = $originalLabels | Where-Object { $_.name -eq $newLabels[$i].name } + $label = $labels | Where-Object { $_.name -eq $newLabels[$i].name } + $originalLabel | Should -BeNullOrEmpty + $label | Should -Not -BeNullOrEmpty + } } } - } Describe 'Adding labels to an issue' { BeforeAll { $repositoryName = [Guid]::NewGuid().Guid $repo = New-GitHubRepository -RepositoryName $repositoryName - $repo | Set-GitHubLabel -Label $defaultLabels + $repo | Initialize-GitHubLabel -Label $defaultLabels } AfterAll { @@ -853,7 +845,7 @@ try BeforeAll { $repositoryName = [Guid]::NewGuid().Guid $repo = New-GitHubRepository -RepositoryName $repositoryName - $repo | Set-GitHubLabel -Label $defaultLabels + $repo | Initialize-GitHubLabel -Label $defaultLabels } AfterAll { @@ -919,7 +911,7 @@ try BeforeAll { $repositoryName = [Guid]::NewGuid().Guid $repo = New-GitHubRepository -RepositoryName $repositoryName - $repo | Set-GitHubLabel -Label $defaultLabels + $repo | Initialize-GitHubLabel -Label $defaultLabels } AfterAll { @@ -1086,7 +1078,7 @@ try BeforeAll { $repositoryName = [Guid]::NewGuid().Guid $repo = New-GitHubRepository -RepositoryName $repositoryName - $repo | Set-GitHubLabel -Label $defaultLabels + $repo | Initialize-GitHubLabel -Label $defaultLabels } AfterAll { @@ -1235,7 +1227,7 @@ try BeforeAll { $repositoryName = [Guid]::NewGuid().Guid $repo = New-GitHubRepository -RepositoryName $repositoryName - $repo | Set-GitHubLabel -Label $defaultLabels + $repo | Initialize-GitHubLabel -Label $defaultLabels $milestone = $repo | New-GitHubMilestone -Title 'test milestone' diff --git a/Tests/GitHubMilestones.tests.ps1 b/Tests/GitHubMilestones.tests.ps1 index 048e5dac..cc6c2b89 100644 --- a/Tests/GitHubMilestones.tests.ps1 +++ b/Tests/GitHubMilestones.tests.ps1 @@ -182,21 +182,21 @@ try $milestone.open_issues | Should -Be 0 } - $issue = $issue | Update-GitHubIssue -Milestone $milestone.MilestoneNumber + $issue = $issue | Set-GitHubIssue -Milestone $milestone.MilestoneNumber $milestone = $milestone | Get-GitHubMilestone It "Should be associated to the milestone now" { $issue.milestone.number | Should -Be $milestone.MilestoneNumber $milestone.open_issues | Should -Be 1 } - $issue = $issue | Update-GitHubIssue -Milestone 0 + $issue = $issue | Set-GitHubIssue -Milestone 0 $milestone = $milestone | Get-GitHubMilestone It 'Should no longer be associated to the milestone' { $issue.milestone | Should -BeNullOrEmpty $milestone.open_issues | Should -Be 0 } - $issue = $issue | Update-GitHubIssue -Milestone $milestone.MilestoneNumber + $issue = $issue | Set-GitHubIssue -Milestone $milestone.MilestoneNumber $milestone = $milestone | Get-GitHubMilestone It "Should be associated to the milestone again" { $issue.milestone.number | Should -Be $milestone.MilestoneNumber diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 37bd6983..9e7a0944 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -662,8 +662,8 @@ try $renamedRepo.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository' } - It "Should be possible to rename with Update-GitHubRepository too" { - $renamedRepo = $repo | Update-GitHubRepository -NewName $newRepoName -Confirm:$false + It "Should be possible to rename with Set-GitHubRepository too" { + $renamedRepo = $repo | Set-GitHubRepository -NewName $newRepoName -Confirm:$false $renamedRepo.name | Should -Be $newRepoName $renamedRepo.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository' } @@ -674,7 +674,7 @@ try } } - Describe 'GitHubRepositories\Update-GitHubRepository' { + Describe 'GitHubRepositories\Set-GitHubRepository' { Context -Name 'When updating a public repository' -Fixture { BeforeAll -ScriptBlock { @@ -699,7 +699,7 @@ try DeleteBranchOnMerge = $true IsTemplate = $true } - $updatedRepo = Update-GitHubRepository @updateGithubRepositoryParms + $updatedRepo = Set-GitHubRepository @updateGithubRepositoryParms } It 'Should return an object of the correct type' { @@ -731,7 +731,7 @@ try DisallowMergeCommit = $false DisallowRebaseMerge = $true } - $updatedRepo = Update-GitHubRepository @updateGithubRepositoryParms + $updatedRepo = Set-GitHubRepository @updateGithubRepositoryParms } It 'Should return an object of the correct type' { @@ -753,7 +753,7 @@ try RepositoryName = $repoName Archived = $true } - $updatedRepo = Update-GitHubRepository @updateGithubRepositoryParms + $updatedRepo = Set-GitHubRepository @updateGithubRepositoryParms } It 'Should return an object of the correct type' { @@ -784,7 +784,7 @@ try RepositoryName = $repoName Private = $false } - $updatedRepo = Update-GitHubRepository @updateGithubRepositoryParms + $updatedRepo = Set-GitHubRepository @updateGithubRepositoryParms } It 'Should return an object of the correct type' { diff --git a/USAGE.md b/USAGE.md index 2b275c61..441081e7 100644 --- a/USAGE.md +++ b/USAGE.md @@ -395,13 +395,16 @@ Remove-GitHubIssueLabel -OwnerName microsoft -RepositoryName DesiredStateConfigu #### Updating a Label With a New Name and Color ```powershell -Update-GitHubLabel -OwnerName microsoft -RepositoryName DesiredStateConfiguration -Name TestLabel -NewName NewTestLabel -Color BBBB00 +Set-GitHubLabel -OwnerName microsoft -RepositoryName DesiredStateConfiguration -Name TestLabel -NewName NewTestLabel -Color BBBB00 ``` #### Bulk Updating Labels in a Repository +This replaces the entire set of labels in a repository to only contain the labels in the provided array. +Any labels already in the repository that are not in this array will be removed upon execution. + ```powershell $labels = @( @{ 'name' = 'Label1'; 'color' = 'BBBB00'; 'description' = 'My label description' }, @{ 'name' = 'Label2'; 'color' = 'FF00000' }) -Set-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -Label $labels +Initialize-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -Label $labels ``` ---------- @@ -413,9 +416,9 @@ Set-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration Get-GitHubUser -Current ``` -#### Updating the current authenticated user +#### Updating the current authenticated user's profile ```powershell -Update-GitHubCurrentUser -Location 'Seattle, WA' -Hireable:$false +Set-GitHubProfile -Location 'Seattle, WA' -Hireable:$false ``` #### Getting any user @@ -569,7 +572,7 @@ $HasPermission = Test-GitHubAssignee -OwnerName microsoft -RepositoryName PowerS #### Add assignee to an issue ```powershell -New-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Assignees $assignees -Issue 1 +Add-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Assignees $assignees -Issue 1 ``` #### Remove assignee from an issue @@ -628,7 +631,7 @@ Get-GitHubMilestone -OwnerName microsoft -RepositoryName PowerShellForGitHub -Mi #### Assign an existing issue to a new milestone ```powershell New-GitHubMilestone -OwnerName microsoft -RepositoryName PowerShellForGitHub -Title "Testing this API" -Update-GitHubIssue -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 2 -Milestone 1 +Set-GitHubIssue -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 2 -Milestone 1 ``` #### Editing an existing milestone @@ -722,5 +725,5 @@ $issue = $repo | New-GitHubIssue -Title $IssueTitle -Body $body -Label 'blog com $issue | New-GitHubIssueComment -Body $CommentBody # Close issue -$issue | Update-GitHubIssue -State Closed +$issue | Set-GitHubIssue -State Closed ```