Skip to content

Commit ef246cd

Browse files
authored
GitHubRepositories: Add Additional Parameters (#192)
This PR adds the following parameters to the `New-GitHubRepository` and `Update-GitHubRepository` functions: - DeleteBranchOnMerge - IsTemplate It also adds substantial UT's to verify these changes. Fixes #189
1 parent 742b853 commit ef246cd

File tree

2 files changed

+419
-71
lines changed

2 files changed

+419
-71
lines changed

GitHubRepositories.ps1

+32-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function New-GitHubRepository
4040
This is only valid when creating a repository in an organization.
4141
4242
.PARAMETER Private
43-
By default, this repository will created Public. Specify this to create
43+
By default, this repository will be created Public. Specify this to create
4444
a private repository.
4545
4646
.PARAMETER NoIssues
@@ -69,6 +69,12 @@ function New-GitHubRepository
6969
By default, rebase-merge pull requests will be allowed.
7070
Specify this to disallow.
7171
72+
.PARAMETER DeleteBranchOnMerge
73+
Specifies the automatic deleting of head branches when pull requests are merged.
74+
75+
.PARAMETER IsTemplate
76+
Specifies whether the repository is made available as a template.
77+
7278
.PARAMETER AccessToken
7379
If provided, this will be used as the AccessToken for authentication with the
7480
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
@@ -120,6 +126,10 @@ function New-GitHubRepository
120126

121127
[switch] $DisallowRebaseMerge,
122128

129+
[switch] $DeleteBranchOnMerge,
130+
131+
[switch] $IsTemplate,
132+
123133
[string] $AccessToken,
124134

125135
[switch] $NoStatus
@@ -163,12 +173,15 @@ function New-GitHubRepository
163173
if ($PSBoundParameters.ContainsKey('DisallowSquashMerge')) { $hashBody['allow_squash_merge'] = (-not $DisallowSquashMerge.ToBool()) }
164174
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
165175
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
176+
if ($PSBoundParameters.ContainsKey('DeleteBranchOnMerge')) { $hashBody['delete_branch_on_merge'] = $DeleteBranchOnMerge.ToBool() }
177+
if ($PSBoundParameters.ContainsKey('IsTemplate')) { $hashBody['is_template'] = $IsTemplate.ToBool() }
166178

167179
$params = @{
168180
'UriFragment' = $uriFragment
169181
'Body' = (ConvertTo-Json -InputObject $hashBody)
170182
'Method' = 'Post'
171-
'Description' = "Creating $RepositoryName"
183+
'AcceptHeader' = $script:baptisteAcceptHeader
184+
'Description' = "Creating $RepositoryName"
172185
'AccessToken' = $AccessToken
173186
'TelemetryEventName' = $MyInvocation.MyCommand.Name
174187
'TelemetryProperties' = $telemetryProperties
@@ -743,6 +756,12 @@ function Update-GitHubRepository
743756
By default, rebase-merge pull requests will be allowed.
744757
Specify this to disallow.
745758
759+
.PARAMETER DeleteBranchOnMerge
760+
Specifies the automatic deleting of head branches when pull requests are merged.
761+
762+
.PARAMETER IsTemplate
763+
Specifies whether the repository is made available as a template.
764+
746765
.PARAMETER Archived
747766
Specify this to archive this repository.
748767
NOTE: You cannot unarchive repositories through the API / this module.
@@ -760,8 +779,12 @@ function Update-GitHubRepository
760779
.EXAMPLE
761780
Update-GitHubRepository -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Description 'The best way to automate your GitHub interactions'
762781
782+
Changes the description of the specified repository.
783+
763784
.EXAMPLE
764785
Update-GitHubRepository -Uri https://github.com./PowerShell/PowerShellForGitHub -Private:$false
786+
787+
Changes the visibility of the specified repository to be public.
765788
#>
766789
[CmdletBinding(
767790
SupportsShouldProcess,
@@ -799,6 +822,10 @@ function Update-GitHubRepository
799822

800823
[switch] $DisallowRebaseMerge,
801824

825+
[switch] $DeleteBranchOnMerge,
826+
827+
[switch] $IsTemplate,
828+
802829
[switch] $Archived,
803830

804831
[string] $AccessToken,
@@ -831,12 +858,15 @@ function Update-GitHubRepository
831858
if ($PSBoundParameters.ContainsKey('DisallowSquashMerge')) { $hashBody['allow_squash_merge'] = (-not $DisallowSquashMerge.ToBool()) }
832859
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
833860
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
861+
if ($PSBoundParameters.ContainsKey('DeleteBranchOnMerge')) { $hashBody['delete_branch_on_merge'] = $DeleteBranchOnMerge.ToBool() }
862+
if ($PSBoundParameters.ContainsKey('IsTemplate')) { $hashBody['is_template'] = $IsTemplate.ToBool() }
834863
if ($PSBoundParameters.ContainsKey('Archived')) { $hashBody['archived'] = $Archived.ToBool() }
835864

836865
$params = @{
837866
'UriFragment' = "repos/$OwnerName/$RepositoryName"
838867
'Body' = (ConvertTo-Json -InputObject $hashBody)
839868
'Method' = 'Patch'
869+
'AcceptHeader' = $script:baptisteAcceptHeader
840870
'Description' = "Updating $RepositoryName"
841871
'AccessToken' = $AccessToken
842872
'TelemetryEventName' = $MyInvocation.MyCommand.Name

0 commit comments

Comments
 (0)