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
This commit is contained in:
Simon Heather 2023-02-27 05:09:25 +00:00 коммит произвёл GitHub
Родитель b976e9515c
Коммит 9baf54e44c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -89,6 +89,10 @@ filter New-GitHubRepository
.PARAMETER AllowAutoMerge
Specifies whether to allow auto-merge on pull requests.
.PARAMETER AllowUpdateBranch
Specifies whether to always allow a pull request head branch that is behind its base branch
to be updated even if it is not required to be up-to-date before merging.
.PARAMETER DeleteBranchOnMerge
Specifies the automatic deleting of head branches when pull requests are merged.
@ -170,6 +174,8 @@ filter New-GitHubRepository
[switch] $AllowAutoMerge,
[switch] $AllowUpdateBranch,
[switch] $DeleteBranchOnMerge,
[switch] $IsTemplate,
@ -217,6 +223,7 @@ filter New-GitHubRepository
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
if ($PSBoundParameters.ContainsKey('AllowAutoMerge')) { $hashBody['allow_auto_merge'] = $AllowAutoMerge.ToBool() }
if ($PSBoundParameters.ContainsKey('AllowUpdateBranch')) { $hashBody['allow_update_branch'] = $AllowUpdateBranch.ToBool() }
if ($PSBoundParameters.ContainsKey('DeleteBranchOnMerge')) { $hashBody['delete_branch_on_merge'] = $DeleteBranchOnMerge.ToBool() }
if ($PSBoundParameters.ContainsKey('IsTemplate')) { $hashBody['is_template'] = $IsTemplate.ToBool() }
@ -1075,6 +1082,10 @@ filter Set-GitHubRepository
.PARAMETER AllowAutoMerge
Specifies whether to allow auto-merge on pull requests.
.PARAMETER AllowUpdateBranch
Specifies whether to always allow a pull request head branch that is behind its base branch
to be updated even if it is not required to be up-to-date before merging.
.PARAMETER DeleteBranchOnMerge
Specifies the automatic deleting of head branches when pull requests are merged.
@ -1181,6 +1192,8 @@ filter Set-GitHubRepository
[switch] $AllowAutoMerge,
[switch] $AllowUpdateBranch,
[switch] $DeleteBranchOnMerge,
[switch] $IsTemplate,
@ -1227,6 +1240,7 @@ filter Set-GitHubRepository
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
if ($PSBoundParameters.ContainsKey('AllowAutoMerge')) { $hashBody['allow_auto_merge'] = $AllowAutoMerge.ToBool() }
if ($PSBoundParameters.ContainsKey('AllowUpdateBranch')) { $hashBody['allow_update_branch'] = $AllowUpdateBranch.ToBool() }
if ($PSBoundParameters.ContainsKey('DeleteBranchOnMerge')) { $hashBody['delete_branch_on_merge'] = $DeleteBranchOnMerge.ToBool() }
if ($PSBoundParameters.ContainsKey('IsTemplate')) { $hashBody['is_template'] = $IsTemplate.ToBool() }
if ($PSBoundParameters.ContainsKey('Archived')) { $hashBody['archived'] = $Archived.ToBool() }

Просмотреть файл

@ -123,6 +123,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' {
DisallowMergeCommit = $true
DisallowRebaseMerge = $false
AllowAutoMerge = $true
AllowUpdateBranch = $true
DeleteBranchOnMerge = $true
GitIgnoreTemplate = $testGitIgnoreTemplate
LicenseTemplate = $testLicenseTemplate
@ -148,6 +149,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' {
$repo.allow_merge_commit | Should -BeFalse
$repo.allow_rebase_merge | Should -BeTrue
$repo.allow_auto_merge | Should -BeTrue
$repo.allow_update_branch | Should -BeTrue
$repo.delete_branch_on_merge | Should -BeTrue
$repo.is_template | Should -BeTrue
}
@ -780,6 +782,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' {
DisallowSquashMerge = $true
DisallowMergeCommit = $true
DisallowRebaseMerge = $false
AllowUpdateBranch = $true
DeleteBranchOnMerge = $true
IsTemplate = $true
}
@ -803,6 +806,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' {
$updatedRepo.allow_squash_merge | Should -BeFalse
$updatedRepo.allow_merge_commit | Should -BeFalse
$updatedRepo.allow_rebase_merge | Should -BeTrue
$updatedRepo.allow_update_branch | Should -BeTrue
$updatedRepo.delete_branch_on_merge | Should -BeTrue
$updatedRepo.is_template | Should -BeTrue
}