Skip to content

Commit 0f9c8c9

Browse files
committed
Updates based on feedback
1 parent 7c04aa0 commit 0f9c8c9

File tree

4 files changed

+85
-70
lines changed

4 files changed

+85
-70
lines changed

GitHubComments.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Get-GitHubComment
2929
Issue number to get comments for. If not supplied, will return back all comments for this repository.
3030
3131
.PARAMETER Sort
32-
How to sort the results, either created or updated. Default: created
32+
How to sort the results, either created or updated.
3333
3434
.PARAMETER Direction
3535
How to list the results, either asc or desc. Ignored without the sort parameter.

GitHubMilestones.ps1

Lines changed: 66 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ function Get-GitHubMilestone
2222
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
2323
them individually.
2424
25-
.PARAMETER MilestoneNumber
25+
.PARAMETER Milestone
2626
The number of a specific milestone to get. If not supplied, will return back all milestones for this repository.
2727
2828
.PARAMETER Sort
29-
How to sort the results, either due_on or completeness. Default: due_on
29+
How to sort the results, either DueOn or Completeness.
3030
3131
.PARAMETER Direction
32-
How to list the results, either asc or desc. Ignored without the sort parameter. Default: asc
32+
How to list the results, either Ascending or Descending. Ignored without the sort parameter.
3333
3434
.PARAMETER State
35-
Only milestones with this state are returned, either open, closed, or all. Default: open
35+
Only milestones with this state are returned, either Open, Closed, or All.
3636
3737
.PARAMETER AccessToken
3838
If provided, this will be used as the AccessToken for authentication with the
@@ -46,40 +46,45 @@ function Get-GitHubMilestone
4646
4747
.EXAMPLE
4848
Get-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub
49-
5049
Get the milestones for the PowerShell\PowerShellForGitHub project.
50+
51+
Get-GitHubMilestone -Uri 'https://github.com/PowerShell/PowerShellForGitHub' -Milestone 1
52+
Get milestone number 1 for the PowerShell\PowerShellForGitHub project.
5153
#>
5254
[CmdletBinding(
5355
SupportsShouldProcess,
5456
DefaultParametersetName='RepositoryElements')]
5557
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
5658
param(
59+
[Parameter(Mandatory, ParameterSetName='MilestoneElements')]
5760
[Parameter(Mandatory, ParameterSetName='RepositoryElements')]
5861
[string] $OwnerName,
5962

63+
[Parameter(Mandatory, ParameterSetName='MilestoneElements')]
6064
[Parameter(Mandatory, ParameterSetName='RepositoryElements')]
6165
[string] $RepositoryName,
6266

67+
[Parameter(Mandatory, ParameterSetName='MilestoneUri')]
6368
[Parameter(Mandatory, ParameterSetName='RepositoryUri')]
6469
[string] $Uri,
6570

66-
[Parameter(ParameterSetName='RepositoryUri')]
67-
[Parameter(ParameterSetName='RepositoryElements')]
68-
[string] $MilestoneNumber,
71+
[Parameter(Mandatory, ParameterSetName='MilestoneUri')]
72+
[Parameter(Mandatory, ParameterSetName='MilestoneElements')]
73+
[int] $Milestone,
6974

7075
[Parameter(ParameterSetName='RepositoryUri')]
7176
[Parameter(ParameterSetName='RepositoryElements')]
72-
[ValidateSet('open', 'closed', 'all')]
77+
[ValidateSet('Open', 'Closed', 'All')]
7378
[string] $State,
7479

7580
[Parameter(ParameterSetName='RepositoryUri')]
7681
[Parameter(ParameterSetName='RepositoryElements')]
77-
[ValidateSet('due_on', 'completeness')]
82+
[ValidateSet('DueOn', 'Completeness')]
7883
[string] $Sort,
7984

8085
[Parameter(ParameterSetName='RepositoryUri')]
8186
[Parameter(ParameterSetName='RepositoryElements')]
82-
[ValidateSet('asc', 'desc')]
87+
[ValidateSet('Ascending', 'Descending')]
8388
[string] $Direction,
8489

8590
[string] $AccessToken,
@@ -96,30 +101,45 @@ function Get-GitHubMilestone
96101
$telemetryProperties = @{
97102
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
98103
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
99-
'ProvidedMilestone' = $PSBoundParameters.ContainsKey('MilestoneNumber')
104+
'ProvidedMilestone' = $PSBoundParameters.ContainsKey('Milestone')
100105
}
101106

102-
if ($PSBoundParameters.ContainsKey('MilestoneNumber'))
107+
if ($PSBoundParameters.ContainsKey('Milestone'))
103108
{
104-
$uriFragment = "repos/$OwnerName/$RepositoryName/milestones/$MilestoneNumber"
105-
$description = "Getting milestone $MilestoneNumber for $RepositoryName"
109+
$uriFragment = "repos/$OwnerName/$RepositoryName/milestones/$Milestone"
110+
$description = "Getting milestone $Milestone for $RepositoryName"
106111
}
107112
else
108113
{
109114
$getParams = @()
110115

111116
if ($PSBoundParameters.ContainsKey('Sort'))
112117
{
113-
$getParams += "sort=$Sort"
118+
if ($Sort -eq "Completeness")
119+
{
120+
$getParams += "sort=completeness"
121+
}
122+
elseif ($Sort -eq "DueOn")
123+
{
124+
$getParams += "sort=due_on"
125+
}
114126
}
115127

116128
if ($PSBoundParameters.ContainsKey('Direction'))
117129
{
118-
$getParams += "direction=$Direction"
130+
if ($Direction -eq "Ascending")
131+
{
132+
$getParams += "direction=asc"
133+
}
134+
elseif ($Direction -eq "Descending")
135+
{
136+
$getParams += "direction=desc"
137+
}
119138
}
120139

121140
if ($PSBoundParameters.ContainsKey('State'))
122141
{
142+
$State = $State.ToLower()
123143
$getParams += "state=$State"
124144
}
125145

@@ -143,7 +163,7 @@ function New-GitHubMilestone
143163
{
144164
<#
145165
.DESCRIPTION
146-
Creates a new Github milestone in an issue for the given repository
166+
Creates a new Github milestone for the given repository
147167
148168
The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
149169
@@ -164,12 +184,12 @@ function New-GitHubMilestone
164184
The title of the milestone.
165185
166186
.PARAMETER State
167-
Only milestones with this state are returned, either open or closed. Default: open
187+
The state of the milestone, either Open or Closed.
168188
169189
.PARAMETER Description
170190
A description of the milestone.
171191
172-
.PARAMETER Due_On
192+
.PARAMETER DueOn
173193
The milestone due date.
174194
175195
.PARAMETER AccessToken
@@ -185,7 +205,7 @@ function New-GitHubMilestone
185205
.EXAMPLE
186206
New-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -Title "Testing this API"
187207
188-
Creates a new Github milestone in an issue for the PowerShell\PowerShellForGitHub project.
208+
Creates a new Github milestone for the PowerShell\PowerShellForGitHub project.
189209
#>
190210
[CmdletBinding(
191211
SupportsShouldProcess,
@@ -205,18 +225,12 @@ function New-GitHubMilestone
205225
[Parameter(Mandatory, ParameterSetName='Elements')]
206226
[string] $Title,
207227

208-
[Parameter(ParameterSetName='Uri')]
209-
[Parameter(ParameterSetName='Elements')]
210-
[ValidateSet('open', 'closed')]
228+
[ValidateSet('Open', 'Closed')]
211229
[string] $State,
212230

213-
[Parameter(ParameterSetName='Uri')]
214-
[Parameter(ParameterSetName='Elements')]
215231
[string] $Description,
216232

217-
[Parameter(ParameterSetName='Uri')]
218-
[Parameter(ParameterSetName='Elements')]
219-
[DateTime] $Due_On,
233+
[DateTime] $DueOn,
220234

221235
[string] $AccessToken,
222236

@@ -241,6 +255,7 @@ function New-GitHubMilestone
241255

242256
if ($PSBoundParameters.ContainsKey('State'))
243257
{
258+
$State = $State.ToLower()
244259
$hashBody.add('state', $State)
245260
}
246261

@@ -249,9 +264,9 @@ function New-GitHubMilestone
249264
$hashBody.add('description', $Description)
250265
}
251266

252-
if ($PSBoundParameters.ContainsKey('Due_On') -and $null -ne $Due_On)
267+
if ($PSBoundParameters.ContainsKey('DueOn'))
253268
{
254-
$DueOnFormattedTime = $Due_On.ToUniversalTime().ToString('o')
269+
$DueOnFormattedTime = $DueOn.ToUniversalTime().ToString('o')
255270
$hashBody.add('due_on', $DueOnFormattedTime)
256271
}
257272

@@ -290,19 +305,19 @@ function Set-GitHubMilestone
290305
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
291306
them individually.
292307
293-
.PARAMETER MilestoneNumber
308+
.PARAMETER Milestone
294309
The number of a specific milestone to get.
295310
296311
.PARAMETER Title
297312
The title of the milestone.
298313
299314
.PARAMETER State
300-
Only milestones with this state are returned, either open or closed. Default: open
315+
The state of the milestone, either Open or Closed.
301316
302317
.PARAMETER Description
303318
A description of the milestone.
304319
305-
.PARAMETER Due_On
320+
.PARAMETER DueOn
306321
The milestone due date.
307322
308323
.PARAMETER AccessToken
@@ -316,7 +331,7 @@ function Set-GitHubMilestone
316331
If not supplied here, the DefaultNoStatus configuration property value will be used.
317332
318333
.EXAMPLE
319-
Set-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -MilestoneNumber 1 -Title "Testing this API"
334+
Set-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -Milestone 1 -Title "Testing this API"
320335
321336
Update an existing milestone for the PowerShell\PowerShellForGitHub project.
322337
#>
@@ -336,24 +351,18 @@ function Set-GitHubMilestone
336351

337352
[Parameter(Mandatory, ParameterSetName='Uri')]
338353
[Parameter(Mandatory, ParameterSetName='Elements')]
339-
[string] $MilestoneNumber,
354+
[int] $Milestone,
340355

341356
[Parameter(Mandatory, ParameterSetName='Uri')]
342357
[Parameter(Mandatory, ParameterSetName='Elements')]
343358
[string] $Title,
344359

345-
[Parameter(ParameterSetName='Uri')]
346-
[Parameter(ParameterSetName='Elements')]
347-
[ValidateSet('open', 'closed')]
360+
[ValidateSet('Open', 'Closed')]
348361
[string] $State,
349362

350-
[Parameter(ParameterSetName='Uri')]
351-
[Parameter(ParameterSetName='Elements')]
352363
[string] $Description,
353364

354-
[Parameter(ParameterSetName='Uri')]
355-
[Parameter(ParameterSetName='Elements')]
356-
[DateTime] $Due_On,
365+
[DateTime] $DueOn,
357366

358367
[string] $AccessToken,
359368

@@ -370,7 +379,7 @@ function Set-GitHubMilestone
370379
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
371380
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
372381
'Title' = (Get-PiiSafeString -PlainText $Title)
373-
'MilestoneNumber' = (Get-PiiSafeString -PlainText $MilestoneNumber)
382+
'Milestone' = (Get-PiiSafeString -PlainText $Milestone)
374383
}
375384

376385
$hashBody = @{
@@ -379,6 +388,7 @@ function Set-GitHubMilestone
379388

380389
if ($PSBoundParameters.ContainsKey('State'))
381390
{
391+
$State = $State.ToLower()
382392
$hashBody.add('state', $State)
383393
}
384394

@@ -387,17 +397,17 @@ function Set-GitHubMilestone
387397
$hashBody.add('description', $Description)
388398
}
389399

390-
if ($PSBoundParameters.ContainsKey('Due_On') -and $null -ne $Due_On)
400+
if ($PSBoundParameters.ContainsKey('DueOn'))
391401
{
392-
$DueOnFormattedTime = $Due_On.ToUniversalTime().ToString('o')
402+
$DueOnFormattedTime = $DueOn.ToUniversalTime().ToString('o')
393403
$hashBody.add('due_on', $DueOnFormattedTime)
394404
}
395405

396406
$params = @{
397-
'UriFragment' = "repos/$OwnerName/$RepositoryName/milestones/$MilestoneNumber"
407+
'UriFragment' = "repos/$OwnerName/$RepositoryName/milestones/$Milestone"
398408
'Body' = (ConvertTo-Json -InputObject $hashBody)
399409
'Method' = 'Patch'
400-
'Description' = "Setting milestone $MilestoneNumber for $RepositoryName"
410+
'Description' = "Setting milestone $Milestone for $RepositoryName"
401411
'AccessToken' = $AccessToken
402412
'TelemetryEventName' = $MyInvocation.MyCommand.Name
403413
'TelemetryProperties' = $telemetryProperties
@@ -428,8 +438,8 @@ function Remove-GitHubMilestone
428438
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
429439
them individually.
430440
431-
.PARAMETER MilestoneNumber
432-
The number of a specific milestone to get.
441+
.PARAMETER Milestone
442+
The number of a specific milestone to delete.
433443
434444
.PARAMETER AccessToken
435445
If provided, this will be used as the AccessToken for authentication with the
@@ -442,7 +452,7 @@ function Remove-GitHubMilestone
442452
If not supplied here, the DefaultNoStatus configuration property value will be used.
443453
444454
.EXAMPLE
445-
Remove-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -MilestoneNumber 1
455+
Remove-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -Milestone 1
446456
447457
Deletes a Github milestone from the PowerShell\PowerShellForGitHub project.
448458
#>
@@ -463,7 +473,7 @@ function Remove-GitHubMilestone
463473

464474
[Parameter(Mandatory, ParameterSetName='Uri')]
465475
[Parameter(Mandatory, ParameterSetName='Elements')]
466-
[string] $MilestoneNumber,
476+
[string] $Milestone,
467477

468478
[string] $AccessToken,
469479

@@ -479,13 +489,13 @@ function Remove-GitHubMilestone
479489
$telemetryProperties = @{
480490
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
481491
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
482-
'MilestoneNumber' = (Get-PiiSafeString -PlainText $MilestoneNumber)
492+
'Milestone' = (Get-PiiSafeString -PlainText $Milestone)
483493
}
484494

485495
$params = @{
486-
'UriFragment' = "repos/$OwnerName/$RepositoryName/milestones/$MilestoneNumber"
496+
'UriFragment' = "repos/$OwnerName/$RepositoryName/milestones/$Milestone"
487497
'Method' = 'Delete'
488-
'Description' = "Removing milestone $MilestoneNumber for $RepositoryName"
498+
'Description' = "Removing milestone $Milestone for $RepositoryName"
489499
'AccessToken' = $AccessToken
490500
'TelemetryEventName' = $MyInvocation.MyCommand.Name
491501
'TelemetryProperties' = $telemetryProperties

0 commit comments

Comments
 (0)