Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optional feature: Remove source branch #71

Merged
merged 5 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dirty-bees-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'changesets-gitlab': minor
---

feat: added new input variable controling if the source branch should be automatically deleted or not
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GitLab CI cli for [changesets](https://github.com/atlassian/changesets) like its

- published - Command executed after published
- only_changesets - Command executed on only changesets detected
- remove_source_branch - Enables the merge request "Delete source branch" checkbox. Default false.
- target_branch -> The merge request target branch. Defaults to current branch

### Outputs
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const main = async ({
mrTitle: getOptionalInput('title'),
mrTargetBranch: getOptionalInput('target_branch'),
commitMessage: getOptionalInput('commit'),
removeSourceBranch: getInput('remove_source_branch') === 'true',
hasPublishScript,
})
if (onlyChangesets) {
Expand Down
4 changes: 4 additions & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ interface VersionOptions {
gitlabToken: string
cwd?: string
mrTitle?: string
removeSourceBranch?: boolean
mrTargetBranch?: string
commitMessage?: string
hasPublishScript?: boolean
Expand All @@ -197,6 +198,7 @@ export async function runVersion({
mrTitle = 'Version Packages',
mrTargetBranch = context.ref,
commitMessage = 'Version Packages',
removeSourceBranch = false,
hasPublishScript = false,
}: VersionOptions) {
const currentBranch = context.ref
Expand Down Expand Up @@ -305,13 +307,15 @@ ${
finalMrTitle,
{
description: await mrBodyPromise,
removeSourceBranch,
},
)
} else {
console.log(`updating found merge request !${searchResult[0].iid}`)
await api.MergeRequests.edit(context.projectId, searchResult[0].iid, {
title: finalMrTitle,
description: await mrBodyPromise,
removeSourceBranch,
})
}
}