Skip to content

Commit

Permalink
Added Discussions support (#382)
Browse files Browse the repository at this point in the history
Allow the user to enable Discussions in Github repositories.

Fixes #378
  • Loading branch information
variableresistor committed Feb 26, 2023
1 parent 5e1a4b3 commit 3ccee43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions GitHubRepositories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -152,6 +155,8 @@ filter New-GitHubRepository

[switch] $NoWiki,

[switch] $HasDiscussions,

[switch] $AutoInit,

[switch] $DisallowSquashMerge,
Expand Down Expand Up @@ -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()) }
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1153,6 +1162,8 @@ filter Set-GitHubRepository

[switch] $NoWiki,

[switch] $HasDiscussions,

[switch] $DisallowSquashMerge,

[switch] $DisallowMergeCommit,
Expand Down Expand Up @@ -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()) }
Expand Down
7 changes: 7 additions & 0 deletions Tests/GitHubRepositories.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -116,6 +118,7 @@ Describe 'GitHubRepositories\New-GitHubRepository' {
NoIssues = $true
NoProjects = $true
NoWiki = $true
HasDiscussions = $true
DisallowSquashMerge = $true
DisallowMergeCommit = $true
DisallowRebaseMerge = $false
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -725,6 +730,7 @@ Describe 'GitHubRepositories\Set-GitHubRepository' {
NoIssues = $true
NoProjects = $true
NoWiki = $true
HasDiscussions = $true
DisallowSquashMerge = $true
DisallowMergeCommit = $true
DisallowRebaseMerge = $false
Expand All @@ -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
Expand Down

0 comments on commit 3ccee43

Please sign in to comment.