Skip to content

Commit

Permalink
Ability to wip/unwip an MR
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-peterson committed Oct 5, 2023
1 parent dd9956f commit 2a542c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/GitlabCli/GitlabCli.psd1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@{
ModuleVersion = '1.102.0'
ModuleVersion = '1.103.0'

PrivateData = @{
PSData = @{
LicenseUri = 'https://github.com/chris-peterson/pwsh-gitlab/blob/main/LICENSE'
ProjectUri = 'https://github.com/chris-peterson/pwsh-gitlab'
ReleaseNotes = 'Allow assigning MRs; make get user easier to use (no need to specify ID vs username vs email address)'
ReleaseNotes = 'Toggle MR draft status'
}
}

Expand Down
40 changes: 28 additions & 12 deletions src/GitlabCli/MergeRequests.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -381,51 +381,67 @@ function Update-GitlabMergeRequest {
[string]
$Title,

[Parameter()]
[Alias('Wip')]
[switch]
$Draft,

[Parameter()]
[Alias('RemoveDraft')]
[Alias('RemoveWip')]
[switch]
$MarkReady,

[Parameter()]
[string]
$Description,

[Parameter(ParameterSetName="Assign")]
[Parameter()]
[string []]
$AssignTo,

[Parameter(ParameterSetName="Unassign")]
[Parameter()]
[switch]
$Unassign,

[Parameter(ParameterSetName="Reviewers")]
[Parameter()]
[string []]
$Reviewers,

[Parameter(ParameterSetName="UnsetReviewers")]
[Parameter()]
[switch]
$UnsetReviewers,

[Parameter(ParameterSetName="Close")]
[Parameter()]
[switch]
$Close,

[Parameter(ParameterSetName="Reopen")]
[Parameter()]
[switch]
$Reopen,

[Parameter()]
[string]
$SiteUrl
)

$Project = Get-GitlabProject -ProjectId $ProjectId
$Request = @{}

if ($Close) {
$Request.state_event = 'close'
}
elseif ($Reopen) {
if ($Reopen) {
$Request.state_event = 'reopen'
}

elseif ($Close) {
$Request.state_event = 'close'
}
if ($Title) {
$Request.title = $Title
} else {
$MergeRequest = Get-GitlabMergeRequest -ProjectId $ProjectId -MergeRequestId $MergeRequestId
if ($Draft -and -not $MergeRequest.Draft) {
$Request.title = "Draft: $($MergeRequest.Title)"
} elseif ($MarkReady -and $MergeRequest.Draft) {
$Request.title = $MergeRequest.Title -replace '^Draft:\s+', ''
}
}
if ($Description) {
$Request.description = $Description
Expand Down

0 comments on commit 2a542c9

Please sign in to comment.