Skip to content
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

Standardize verb usage within the module #228

Merged
merged 6 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions GitHubAssignees.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ filter Test-GitHubAssignee
}
}

function New-GitHubAssignee
function Add-GitHubAssignee
{
<#
.DESCRIPTION
Expand Down Expand Up @@ -308,15 +308,15 @@ 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.

.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.
Expand All @@ -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.
Expand All @@ -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(
Expand Down
9 changes: 5 additions & 4 deletions GitHubIssues.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')]
Expand Down
15 changes: 8 additions & 7 deletions GitHubLabels.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ filter Remove-GitHubLabel
}
}

filter Update-GitHubLabel
filter Set-GitHubLabel
{
<#
.SYNOPSIS
Expand Down Expand Up @@ -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.
Expand All @@ -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')]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down
13 changes: 7 additions & 6 deletions GitHubRepositories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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')]
Expand Down
9 changes: 5 additions & 4 deletions GitHubUsers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
17 changes: 11 additions & 6 deletions PowerShellForGitHub.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

# Functions to export from this module
FunctionsToExport = @(
'Add-GitHubAssignee',
'Add-GitHubIssueLabel',
'Backup-GitHubConfiguration',
'Clear-GitHubAuthentication',
Expand Down Expand Up @@ -102,14 +103,14 @@
'Get-GitHubViewTraffic',
'Group-GitHubIssue',
'Group-GitHubPullRequest',
'Initialize-GitHubLabel',
'Invoke-GHRestMethod',
'Invoke-GHRestMethodMultipleResult',
'Join-GitHubUri',
'Lock-GitHubIssue',
'Move-GitHubProjectCard',
'Move-GitHubProjectColumn',
'Move-GitHubRepositoryOwnership',
'New-GitHubAssignee',
'New-GitHubIssue',
'New-GitHubIssueComment',
'New-GitHubLabel',
Expand All @@ -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 = @(
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Tests/GitHubAssignees.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/GitHubEvents.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down Expand Up @@ -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' {
Expand All @@ -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)
}

Expand Down
Loading