Skip to content

Commit

Permalink
Merge pull request #85 from CaseyMacPherson/SetNewPropertyOnProject
Browse files Browse the repository at this point in the history
Setting only_allow_merge_if_all_discussions_are_resolved on a project
  • Loading branch information
chris-peterson authored Oct 19, 2023
2 parents a04a943 + 3e1d7fa commit cadafb4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/GitlabCli/Projects.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ function Update-GitlabProject {
[string]
$BuildsAccessLevel,

[Parameter(Mandatory=$false)]
[switch]
$OnlyAllowMergeIfAllDiscussionsAreResolved,

[Parameter(Mandatory=$false)]
[string]
$SiteUrl
Expand Down Expand Up @@ -481,7 +485,16 @@ function Update-GitlabProject {
$Query.builds_access_level = $BuildsAccessLevel
}

if ($PSCmdlet.ShouldProcess("$($Project.PathWithNamespace)", "update project ($($Query | ConvertTo-Json))")) {
if($PSBoundParameters.ContainsKey("OnlyAllowMergeIfAllDiscussionsAreResolved") -and `
$Project.OnlyAllowMergeIfAllDiscussionsAreResolved -ne $OnlyAllowMergeIfAllDiscussionsAreResolved
) {
$Query.only_allow_merge_if_all_discussions_are_resolved = $OnlyAllowMergeIfAllDiscussionsAreResolved
}

if($Query.Keys.Count -le 0) {
Write-Host "Nothing to update"
$Project
} elseif ($PSCmdlet.ShouldProcess("$($Project.PathWithNamespace)", "update project ($($Query | ConvertTo-Json))")) {
Invoke-GitlabApi PUT "projects/$($Project.Id)" $Query -SiteUrl $SiteUrl |
New-WrapperObject 'Gitlab.Project'
}
Expand Down

0 comments on commit cadafb4

Please sign in to comment.