From 3ccee43287e053a4ad9f9729a943e75ad12ce904 Mon Sep 17 00:00:00 2001 From: Neil White Date: Sun, 26 Feb 2023 12:10:01 -0800 Subject: [PATCH] Added Discussions support (#382) Allow the user to enable Discussions in Github repositories. Fixes #378 --- GitHubRepositories.ps1 | 12 ++++++++++++ Tests/GitHubRepositories.tests.ps1 | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/GitHubRepositories.ps1 b/GitHubRepositories.ps1 index 464f4856..fc8c46bd 100644 --- a/GitHubRepositories.ps1 +++ b/GitHubRepositories.ps1 @@ -68,6 +68,9 @@ filter New-GitHubRepository .PARAMETER NoWiki By default, this repository will have a Wiki. Specify this to disable the Wiki. + .PARAMETER HasDiscussions + By default, this repository will not have Discussions. Specify this to enable Discussions. + .PARAMETER AutoInit Specify this to create an initial commit with an empty README. @@ -152,6 +155,8 @@ filter New-GitHubRepository [switch] $NoWiki, + [switch] $HasDiscussions, + [switch] $AutoInit, [switch] $DisallowSquashMerge, @@ -201,6 +206,7 @@ filter New-GitHubRepository if ($PSBoundParameters.ContainsKey('NoIssues')) { $hashBody['has_issues'] = (-not $NoIssues.ToBool()) } if ($PSBoundParameters.ContainsKey('NoProjects')) { $hashBody['has_projects'] = (-not $NoProjects.ToBool()) } if ($PSBoundParameters.ContainsKey('NoWiki')) { $hashBody['has_wiki'] = (-not $NoWiki.ToBool()) } + if ($PSBoundParameters.ContainsKey('HasDiscussions')) { $hashBody['has_discussions'] = ( $HasDiscussions.ToBool()) } if ($PSBoundParameters.ContainsKey('AutoInit')) { $hashBody['auto_init'] = $AutoInit.ToBool() } if ($PSBoundParameters.ContainsKey('DisallowSquashMerge')) { $hashBody['allow_squash_merge'] = (-not $DisallowSquashMerge.ToBool()) } if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) } @@ -1045,6 +1051,9 @@ filter Set-GitHubRepository .PARAMETER NoWiki By default, this repository will have a Wiki. Specify this to disable the Wiki. + .PARAMETER HasDiscussions + By default, this repository will not have Discussions. Specify this to enable Discussions. + .PARAMETER DisallowSquashMerge By default, squash-merging pull requests will be allowed. Specify this to disallow. @@ -1153,6 +1162,8 @@ filter Set-GitHubRepository [switch] $NoWiki, + [switch] $HasDiscussions, + [switch] $DisallowSquashMerge, [switch] $DisallowMergeCommit, @@ -1200,6 +1211,7 @@ filter Set-GitHubRepository if ($PSBoundParameters.ContainsKey('NoIssues')) { $hashBody['has_issues'] = (-not $NoIssues.ToBool()) } if ($PSBoundParameters.ContainsKey('NoProjects')) { $hashBody['has_projects'] = (-not $NoProjects.ToBool()) } if ($PSBoundParameters.ContainsKey('NoWiki')) { $hashBody['has_wiki'] = (-not $NoWiki.ToBool()) } + if ($PSBoundParameters.ContainsKey('HasDiscussions')) { $hashBody['has_discussions'] = ( $HasDiscussions.ToBool()) } if ($PSBoundParameters.ContainsKey('DisallowSquashMerge')) { $hashBody['allow_squash_merge'] = (-not $DisallowSquashMerge.ToBool()) } if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) } if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) } diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 0d5e5d8d..910b73d3 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -51,6 +51,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' { $repo.has_issues | Should -BeTrue $repo.has_projects | Should -BeTrue $repo.has_Wiki | Should -BeTrue + $repo.has_discussions | Should -BeFalse $repo.allow_squash_merge | Should -BeTrue $repo.allow_merge_commit | Should -BeTrue $repo.allow_rebase_merge | Should -BeTrue @@ -88,6 +89,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' { $repo.has_issues | Should -BeTrue $repo.has_projects | Should -BeTrue $repo.has_Wiki | Should -BeTrue + $repo.has_discussions | Should -BeFalse $repo.allow_squash_merge | Should -BeTrue $repo.allow_merge_commit | Should -BeTrue $repo.allow_rebase_merge | Should -BeTrue @@ -116,6 +118,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' { NoIssues = $true NoProjects = $true NoWiki = $true + HasDiscussions = $true DisallowSquashMerge = $true DisallowMergeCommit = $true DisallowRebaseMerge = $false @@ -139,6 +142,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' { $repo.has_issues | Should -BeFalse $repo.has_projects | Should -BeFalse $repo.has_Wiki | Should -BeFalse + $repo.has_discussions | Should -BeTrue $repo.allow_squash_merge | Should -BeFalse $repo.allow_merge_commit | Should -BeFalse $repo.allow_rebase_merge | Should -BeTrue @@ -235,6 +239,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' { $repo.has_issues | Should -BeTrue $repo.has_projects | Should -BeTrue $repo.has_Wiki | Should -BeTrue + $repo.has_discussions | Should -BeFalse $repo.allow_squash_merge | Should -BeTrue $repo.allow_merge_commit | Should -BeTrue $repo.allow_rebase_merge | Should -BeTrue @@ -725,6 +730,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' { NoIssues = $true NoProjects = $true NoWiki = $true + HasDiscussions = $true DisallowSquashMerge = $true DisallowMergeCommit = $true DisallowRebaseMerge = $false @@ -747,6 +753,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' { $updatedRepo.has_issues | Should -BeFalse $updatedRepo.has_projects | Should -BeFalse $updatedRepo.has_Wiki | Should -BeFalse + $updatedRepo.has_discussions | Should -BeTrue $updatedRepo.allow_squash_merge | Should -BeFalse $updatedRepo.allow_merge_commit | Should -BeFalse $updatedRepo.allow_rebase_merge | Should -BeTrue