Skip to content

Commit 9baf54e

Browse files
authored
New/Set-GitHubRepository: Add Support for 'Allow Update Branch' Option
Adds the `AllowUpdateBranch` parameter to the `New-GitHubRepository` and `Set-GitHubRepository` functions. Fixes #386 References: - https://docs.github.com/en/rest/repos/repos#create-an-organization-repository - https://docs.github.com/en/rest/repos/repos#update-a-repository
1 parent b976e95 commit 9baf54e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

GitHubRepositories.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ filter New-GitHubRepository
8989
.PARAMETER AllowAutoMerge
9090
Specifies whether to allow auto-merge on pull requests.
9191
92+
.PARAMETER AllowUpdateBranch
93+
Specifies whether to always allow a pull request head branch that is behind its base branch
94+
to be updated even if it is not required to be up-to-date before merging.
95+
9296
.PARAMETER DeleteBranchOnMerge
9397
Specifies the automatic deleting of head branches when pull requests are merged.
9498
@@ -170,6 +174,8 @@ filter New-GitHubRepository
170174

171175
[switch] $AllowAutoMerge,
172176

177+
[switch] $AllowUpdateBranch,
178+
173179
[switch] $DeleteBranchOnMerge,
174180

175181
[switch] $IsTemplate,
@@ -217,6 +223,7 @@ filter New-GitHubRepository
217223
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
218224
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
219225
if ($PSBoundParameters.ContainsKey('AllowAutoMerge')) { $hashBody['allow_auto_merge'] = $AllowAutoMerge.ToBool() }
226+
if ($PSBoundParameters.ContainsKey('AllowUpdateBranch')) { $hashBody['allow_update_branch'] = $AllowUpdateBranch.ToBool() }
220227
if ($PSBoundParameters.ContainsKey('DeleteBranchOnMerge')) { $hashBody['delete_branch_on_merge'] = $DeleteBranchOnMerge.ToBool() }
221228
if ($PSBoundParameters.ContainsKey('IsTemplate')) { $hashBody['is_template'] = $IsTemplate.ToBool() }
222229

@@ -1075,6 +1082,10 @@ filter Set-GitHubRepository
10751082
.PARAMETER AllowAutoMerge
10761083
Specifies whether to allow auto-merge on pull requests.
10771084
1085+
.PARAMETER AllowUpdateBranch
1086+
Specifies whether to always allow a pull request head branch that is behind its base branch
1087+
to be updated even if it is not required to be up-to-date before merging.
1088+
10781089
.PARAMETER DeleteBranchOnMerge
10791090
Specifies the automatic deleting of head branches when pull requests are merged.
10801091
@@ -1181,6 +1192,8 @@ filter Set-GitHubRepository
11811192

11821193
[switch] $AllowAutoMerge,
11831194

1195+
[switch] $AllowUpdateBranch,
1196+
11841197
[switch] $DeleteBranchOnMerge,
11851198

11861199
[switch] $IsTemplate,
@@ -1227,6 +1240,7 @@ filter Set-GitHubRepository
12271240
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
12281241
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
12291242
if ($PSBoundParameters.ContainsKey('AllowAutoMerge')) { $hashBody['allow_auto_merge'] = $AllowAutoMerge.ToBool() }
1243+
if ($PSBoundParameters.ContainsKey('AllowUpdateBranch')) { $hashBody['allow_update_branch'] = $AllowUpdateBranch.ToBool() }
12301244
if ($PSBoundParameters.ContainsKey('DeleteBranchOnMerge')) { $hashBody['delete_branch_on_merge'] = $DeleteBranchOnMerge.ToBool() }
12311245
if ($PSBoundParameters.ContainsKey('IsTemplate')) { $hashBody['is_template'] = $IsTemplate.ToBool() }
12321246
if ($PSBoundParameters.ContainsKey('Archived')) { $hashBody['archived'] = $Archived.ToBool() }

Tests/GitHubRepositories.tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' {
123123
DisallowMergeCommit = $true
124124
DisallowRebaseMerge = $false
125125
AllowAutoMerge = $true
126+
AllowUpdateBranch = $true
126127
DeleteBranchOnMerge = $true
127128
GitIgnoreTemplate = $testGitIgnoreTemplate
128129
LicenseTemplate = $testLicenseTemplate
@@ -148,6 +149,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' {
148149
$repo.allow_merge_commit | Should -BeFalse
149150
$repo.allow_rebase_merge | Should -BeTrue
150151
$repo.allow_auto_merge | Should -BeTrue
152+
$repo.allow_update_branch | Should -BeTrue
151153
$repo.delete_branch_on_merge | Should -BeTrue
152154
$repo.is_template | Should -BeTrue
153155
}
@@ -780,6 +782,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' {
780782
DisallowSquashMerge = $true
781783
DisallowMergeCommit = $true
782784
DisallowRebaseMerge = $false
785+
AllowUpdateBranch = $true
783786
DeleteBranchOnMerge = $true
784787
IsTemplate = $true
785788
}
@@ -803,6 +806,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' {
803806
$updatedRepo.allow_squash_merge | Should -BeFalse
804807
$updatedRepo.allow_merge_commit | Should -BeFalse
805808
$updatedRepo.allow_rebase_merge | Should -BeTrue
809+
$updatedRepo.allow_update_branch | Should -BeTrue
806810
$updatedRepo.delete_branch_on_merge | Should -BeTrue
807811
$updatedRepo.is_template | Should -BeTrue
808812
}

0 commit comments

Comments
 (0)