Skip to content

Commit e57a956

Browse files
Standardize verb usage within the module (#228)
This attempts to rectify some improper verb usage in the module based on the explanations of intended verb usage from [previous PowerShell documentation](https://web.archive.org/web/20171222220053/https://msdn.microsoft.com/en-us/library/windows/desktop/ms714428(v=vs.85).aspx). * We're standardizing on the following pattern for most object actions: `Get` / `Set` / `New` / `Remove` * We will continue to alias `Remove-*` as `Delete-*`. * When possible, this change attempts to avoid breaking changes by re-aliasing the newly named functions with their previous names. This was not possible in one instance, hence this is still a breaking change (although based on telemetry, it should be minimally impacting). Result: * `Update-GitHubCurrentUser` -> `Set-GitHubProfile` `[Alias('Update-GitHubCurrentUser')]` * `Update-GitHubIssue` -> `Set-GitHubIssue` `[Alias('Update-GitHubIssue')]` * `Update-GitHubRepository` -> `Set-GitHubRepository` `[Alias('Update-GitHubRepository')]` * `New-GitHubAssignee` -> `Add-GitHubAssignee` `[Alias('New-GitHubAssignee')]` * [breaking] `Update-GitHubLabel` -> `Set-GitHubLabel` `[Alias('Update-GitHubLabel')]` * [breaking] `Set-GitHubLabel` -> `Initialize-GitHubLabel` `<no alias due to above>` Changing an existing label has much more regular usage than replacing all of the labels in a repository, hence allowing the _new_ `Set-GitHubLabel` to keep the alias of `Update-GitHubLabel`. Our usage of the `Set-*` verb in general is a bit arguable based on the documentation ... in theory `Edit-*` might be a better fit since we're _editing_ aspects of an object as opposed to _replacing_ the entire content of an object. However, I think `Set-*` _feels_ ok in this module. We're _setting_ the state of these objects. Again...arguable, but this is a much smaller breaking change to get to a consistent terminology state.
1 parent d32bd11 commit e57a956

13 files changed

+105
-100
lines changed

GitHubAssignees.ps1

+6-5
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ filter Test-GitHubAssignee
247247
}
248248
}
249249

250-
function New-GitHubAssignee
250+
function Add-GitHubAssignee
251251
{
252252
<#
253253
.DESCRIPTION
@@ -308,15 +308,15 @@ function New-GitHubAssignee
308308
309309
.EXAMPLE
310310
$assignees = @('octocat')
311-
New-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1 -Assignee $assignee
311+
Add-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1 -Assignee $assignee
312312
313313
Additionally assigns the usernames in $assignee to Issue #1
314314
from the microsoft\PowerShellForGitHub project.
315315
316316
.EXAMPLE
317317
$assignees = @('octocat')
318318
$repo = Get-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub
319-
$repo | New-GitHubAssignee -Issue 1 -Assignee $assignee
319+
$repo | Add-GitHubAssignee -Issue 1 -Assignee $assignee
320320
321321
Additionally assigns the usernames in $assignee to Issue #1
322322
from the microsoft\PowerShellForGitHub project.
@@ -325,14 +325,14 @@ function New-GitHubAssignee
325325
$assignees = @('octocat')
326326
Get-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub |
327327
Get-GitHubIssue -Issue 1 |
328-
New-GitHubAssignee -Assignee $assignee
328+
Add-GitHubAssignee -Assignee $assignee
329329
330330
Additionally assigns the usernames in $assignee to Issue #1
331331
from the microsoft\PowerShellForGitHub project.
332332
333333
.EXAMPLE
334334
$octocat = Get-GitHubUser -UserName 'octocat'
335-
$octocat | New-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1
335+
$octocat | Add-GitHubAssignee -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 1
336336
337337
Additionally assigns the user 'octocat' to Issue #1
338338
from the microsoft\PowerShellForGitHub project.
@@ -341,6 +341,7 @@ function New-GitHubAssignee
341341
SupportsShouldProcess,
342342
DefaultParameterSetName='Elements')]
343343
[OutputType({$script:GitHubIssueTypeName})]
344+
[Alias('New-GitHubAssignee')] # Non-standard usage of the New verb, but done to avoid a breaking change post 0.14.0
344345
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
345346
[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.")]
346347
param(

GitHubIssues.ps1

+5-4
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,14 @@ filter New-GitHubIssue
654654
return (Invoke-GHRestMethod @params | Add-GitHubIssueAdditionalProperties)
655655
}
656656

657-
filter Update-GitHubIssue
657+
filter Set-GitHubIssue
658658
{
659659
<#
660660
.SYNOPSIS
661-
Create a new Issue on GitHub.
661+
Updates an Issue on GitHub.
662662
663663
.DESCRIPTION
664-
Create a new Issue on GitHub.
664+
Updates an Issue on GitHub.
665665
666666
The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
667667
@@ -744,12 +744,13 @@ filter Update-GitHubIssue
744744
GitHub.Issue
745745
746746
.EXAMPLE
747-
Update-GitHubIssue -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -State Closed
747+
Set-GitHubIssue -OwnerName microsoft -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -State Closed
748748
#>
749749
[CmdletBinding(
750750
SupportsShouldProcess,
751751
DefaultParameterSetName='Elements')]
752752
[OutputType({$script:GitHubIssueTypeName})]
753+
[Alias('Update-GitHubIssue')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0
753754
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
754755
param(
755756
[Parameter(ParameterSetName='Elements')]

GitHubLabels.ps1

+8-7
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ filter Remove-GitHubLabel
486486
}
487487
}
488488

489-
filter Update-GitHubLabel
489+
filter Set-GitHubLabel
490490
{
491491
<#
492492
.SYNOPSIS
@@ -555,7 +555,7 @@ filter Update-GitHubLabel
555555
GitHub.Label
556556
557557
.EXAMPLE
558-
Update-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label TestLabel -NewName NewTestLabel -Color BBBB00
558+
Set-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label TestLabel -NewName NewTestLabel -Color BBBB00
559559
560560
Updates the existing label called TestLabel in the PowerShellForGitHub project to be called
561561
'NewTestLabel' and be colored yellow.
@@ -564,6 +564,7 @@ filter Update-GitHubLabel
564564
SupportsShouldProcess,
565565
DefaultParameterSetName='Elements')]
566566
[OutputType({$script:GitHubLabelTypeName})]
567+
[Alias('Update-GitHubLabel')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0
567568
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
568569
param(
569570
[Parameter(ParameterSetName='Elements')]
@@ -637,15 +638,15 @@ filter Update-GitHubLabel
637638
return (Invoke-GHRestMethod @params | Add-GitHubLabelAdditionalProperties)
638639
}
639640

640-
filter Set-GitHubLabel
641+
filter Initialize-GitHubLabel
641642
{
642643
<#
643644
.SYNOPSIS
644-
Sets the entire set of Labels on the given GitHub repository to match the provided list
645+
Replaces the entire set of Labels on the given GitHub repository to match the provided list
645646
of Labels.
646647
647648
.DESCRIPTION
648-
Sets the entire set of Labels on the given GitHub repository to match the provided list
649+
Replaces the entire set of Labels on the given GitHub repository to match the provided list
649650
of Labels.
650651
651652
Will update the color/description for any Labels already in the repository that match the
@@ -697,7 +698,7 @@ filter Set-GitHubLabel
697698
GitHub.Repository
698699
699700
.EXAMPLE
700-
Set-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label @(@{'name' = 'TestLabel'; 'color' = 'EEEEEE'}, @{'name' = 'critical'; 'color' = 'FF000000'; 'description' = 'Needs immediate attention'})
701+
Initialize-GitHubLabel -OwnerName microsoft -RepositoryName PowerShellForGitHub -Label @(@{'name' = 'TestLabel'; 'color' = 'EEEEEE'}, @{'name' = 'critical'; 'color' = 'FF000000'; 'description' = 'Needs immediate attention'})
701702
702703
Removes any labels not in this Label array, ensure the current assigned color and descriptions
703704
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
769770
else
770771
{
771772
# Update label's color if it already exists
772-
$null = Update-GitHubLabel -Label $labelToConfigure.name -NewName $labelToConfigure.name -Color $labelToConfigure.color @commonParams
773+
$null = Set-GitHubLabel -Label $labelToConfigure.name -NewName $labelToConfigure.name -Color $labelToConfigure.color @commonParams
773774
}
774775
}
775776

GitHubRepositories.ps1

+7-6
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,11 @@ filter Rename-GitHubRepository
10151015
)
10161016

10171017
# This method was created by mistake and is now retained to avoid a breaking change.
1018-
# Update-GitHubRepository is able to handle this scenario just fine.
1019-
return Update-GitHubRepository @PSBoundParameters
1018+
# Set-GitHubRepository is able to handle this scenario just fine.
1019+
return Set-GitHubRepository @PSBoundParameters
10201020
}
10211021

1022-
filter Update-GitHubRepository
1022+
filter Set-GitHubRepository
10231023
{
10241024
<#
10251025
.SYNOPSIS
@@ -1125,18 +1125,18 @@ filter Update-GitHubRepository
11251125
GitHub.Repository
11261126
11271127
.EXAMPLE
1128-
Update-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub -Description 'The best way to automate your GitHub interactions'
1128+
Set-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub -Description 'The best way to automate your GitHub interactions'
11291129
11301130
Changes the description of the specified repository.
11311131
11321132
.EXAMPLE
1133-
Update-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub -Private:$false
1133+
Set-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub -Private:$false
11341134
11351135
Changes the visibility of the specified repository to be public.
11361136
11371137
.EXAMPLE
11381138
Get-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub |
1139-
Update-GitHubRepository -NewName 'PoShForGitHub' -Force
1139+
Set-GitHubRepository -NewName 'PoShForGitHub' -Force
11401140
11411141
Renames the repository without any user confirmation prompting. This is identical to using
11421142
Rename-GitHubRepository -Uri https://github.com/PowerShell/PowerShellForGitHub -NewName 'PoShForGitHub' -Confirm:$false
@@ -1146,6 +1146,7 @@ filter Update-GitHubRepository
11461146
DefaultParameterSetName='Elements',
11471147
ConfirmImpact='High')]
11481148
[OutputType({$script:GitHubRepositoryTypeName})]
1149+
[Alias('Update-GitHubRepository')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0
11491150
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
11501151
param(
11511152
[Parameter(ParameterSetName='Elements')]

GitHubUsers.ps1

+5-4
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ filter Get-GitHubUserContextualInformation
300300
return $result
301301
}
302302

303-
function Update-GitHubCurrentUser
303+
function Set-GitHubProfile
304304
{
305305
<#
306306
.SYNOPSIS
307-
Updates information about the current authenticated user on GitHub.
307+
Updates profile information for the current authenticated user on GitHub.
308308
309309
.DESCRIPTION
310-
Updates information about the current authenticated user on GitHub.
310+
Updates profile information for the current authenticated user on GitHub.
311311
312312
The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
313313
@@ -347,13 +347,14 @@ function Update-GitHubCurrentUser
347347
GitHub.User
348348
349349
.EXAMPLE
350-
Update-GitHubCurrentUser -Location 'Seattle, WA' -Hireable:$false
350+
Set-GitHubProfile -Location 'Seattle, WA' -Hireable:$false
351351
352352
Updates the current user to indicate that their location is "Seattle, WA" and that they
353353
are not currently hireable.
354354
#>
355355
[CmdletBinding(SupportsShouldProcess)]
356356
[OutputType({$script:GitHubUserTypeName})]
357+
[Alias('Update-GitHubCurrentUser')] # Non-standard usage of the Update verb, but done to avoid a breaking change post 0.14.0
357358
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
358359
param(
359360
[string] $Name,

PowerShellForGitHub.psd1

+11-6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
# Functions to export from this module
5757
FunctionsToExport = @(
58+
'Add-GitHubAssignee',
5859
'Add-GitHubIssueLabel',
5960
'Backup-GitHubConfiguration',
6061
'Clear-GitHubAuthentication',
@@ -102,14 +103,14 @@
102103
'Get-GitHubViewTraffic',
103104
'Group-GitHubIssue',
104105
'Group-GitHubPullRequest',
106+
'Initialize-GitHubLabel',
105107
'Invoke-GHRestMethod',
106108
'Invoke-GHRestMethodMultipleResult',
107109
'Join-GitHubUri',
108110
'Lock-GitHubIssue',
109111
'Move-GitHubProjectCard',
110112
'Move-GitHubProjectColumn',
111113
'Move-GitHubRepositoryOwnership',
112-
'New-GitHubAssignee',
113114
'New-GitHubIssue',
114115
'New-GitHubIssueComment',
115116
'New-GitHubLabel',
@@ -136,24 +137,23 @@
136137
'Set-GitHubAuthentication',
137138
'Set-GitHubConfiguration',
138139
'Set-GitHubContent',
140+
'Set-GitHubIssue',
139141
'Set-GitHubIssueComment',
140142
'Set-GitHubIssueLabel',
141143
'Set-GitHubLabel',
142144
'Set-GitHubMilestone',
145+
'Set-GitHubProfile',
143146
'Set-GitHubProject',
144147
'Set-GitHubProjectCard',
145148
'Set-GitHubProjectColumn',
149+
'Set-GitHubRepository'
146150
'Set-GitHubRepositoryTopic',
147151
'Split-GitHubUri',
148152
'Test-GitHubAssignee',
149153
'Test-GitHubAuthenticationConfigured',
150154
'Test-GitHubOrganizationMember',
151155
'Test-GitHubRepositoryVulnerabilityAlert',
152-
'Unlock-GitHubIssue',
153-
'Update-GitHubCurrentUser',
154-
'Update-GitHubIssue',
155-
'Update-GitHubLabel',
156-
'Update-GitHubRepository'
156+
'Unlock-GitHubIssue'
157157
)
158158

159159
AliasesToExport = @(
@@ -167,10 +167,15 @@
167167
'Delete-GitHubRepository',
168168
'Get-GitHubBranch',
169169
'Get-GitHubComment',
170+
'New-GitHubAssignee',
170171
'New-GitHubComment',
171172
'Remove-GitHubComment',
172173
'Set-GitHubComment',
173174
'Transfer-GitHubRepositoryOwnership'
175+
'Update-GitHubIssue',
176+
'Update-GitHubLabel',
177+
'Update-GitHubCurrentUser',
178+
'Update-GitHubRepository'
174179
)
175180

176181
# Cmdlets to export from this module

Tests/GitHubAssignees.tests.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ try
112112
$issue.assignees | Should -BeNullOrEmpty
113113
}
114114

115-
$updatedIssue = New-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number -Assignee $owner.login
115+
$updatedIssue = Add-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number -Assignee $owner.login
116116
It 'Should have returned the same issue' {
117117
$updatedIssue.number | Should -Be $issue.number
118118
}
@@ -149,7 +149,7 @@ try
149149
$issue.assignees | Should -BeNullOrEmpty
150150
}
151151

152-
$updatedIssue = $repo | New-GitHubAssignee -Issue $issue.number -Assignee $owner.login
152+
$updatedIssue = $repo | Add-GitHubAssignee -Issue $issue.number -Assignee $owner.login
153153
It 'Should have returned the same issue' {
154154
$updatedIssue.number | Should -Be $issue.number
155155
}
@@ -186,7 +186,7 @@ try
186186
$issue.assignees | Should -BeNullOrEmpty
187187
}
188188

189-
$updatedIssue = $issue | New-GitHubAssignee -Assignee $owner.login
189+
$updatedIssue = $issue | Add-GitHubAssignee -Assignee $owner.login
190190
It 'Should have returned the same issue' {
191191
$updatedIssue.number | Should -Be $issue.number
192192
}
@@ -223,7 +223,7 @@ try
223223
$issue.assignees | Should -BeNullOrEmpty
224224
}
225225

226-
$updatedIssue = $owner | New-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number
226+
$updatedIssue = $owner | Add-GitHubAssignee -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $issue.number
227227
It 'Should have returned the same issue' {
228228
$updatedIssue.number | Should -Be $issue.number
229229
}

Tests/GitHubEvents.tests.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ try
4545

4646
Context 'For getting Issue events from a repository' {
4747
$issue = $repo | New-GitHubIssue -Title 'New Issue'
48-
$issue = $issue | Update-GitHubIssue -State Closed
48+
$issue = $issue | Set-GitHubIssue -State Closed
4949
$events = @($repo | Get-GitHubEvent)
5050

5151
It 'Should have an event from closing an issue' {
@@ -82,8 +82,8 @@ try
8282
}
8383

8484
Context 'For getting events from an issue' {
85-
$issue = $issue | Update-GitHubIssue -State Closed
86-
$issue = $issue | Update-GitHubIssue -State Open
85+
$issue = $issue | Set-GitHubIssue -State Closed
86+
$issue = $issue | Set-GitHubIssue -State Open
8787
$events = @(Get-GitHubEvent -OwnerName $ownerName -RepositoryName $repositoryName)
8888

8989
It 'Should have two events from closing and opening the issue' {
@@ -98,8 +98,8 @@ try
9898
$repositoryName = [Guid]::NewGuid()
9999
$repo = New-GitHubRepository -RepositoryName $repositoryName
100100
$issue = $repo | New-GitHubIssue -Title 'New Issue'
101-
$issue = $issue | Update-GitHubIssue -State Closed
102-
$issue = $issue | Update-GitHubIssue -State Open
101+
$issue = $issue | Set-GitHubIssue -State Closed
102+
$issue = $issue | Set-GitHubIssue -State Open
103103
$events = @($repo | Get-GitHubEvent)
104104
}
105105

0 commit comments

Comments
 (0)