Skip to content

Commit 19466b9

Browse files
authored
Optional feature: Remove source branch (#71)
1 parent 85feab5 commit 19466b9

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

.changeset/dirty-bees-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'changesets-gitlab': minor
3+
---
4+
5+
feat: added new input variable controling if the source branch should be automatically deleted or not

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ GitLab CI cli for [changesets](https://github.com/atlassian/changesets) like its
2828

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

3334
### Outputs

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export const main = async ({
105105
mrTitle: getOptionalInput('title'),
106106
mrTargetBranch: getOptionalInput('target_branch'),
107107
commitMessage: getOptionalInput('commit'),
108+
removeSourceBranch: getInput('remove_source_branch') === 'true',
108109
hasPublishScript,
109110
})
110111
if (onlyChangesets) {

src/run.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ interface VersionOptions {
185185
gitlabToken: string
186186
cwd?: string
187187
mrTitle?: string
188+
removeSourceBranch?: boolean
188189
mrTargetBranch?: string
189190
commitMessage?: string
190191
hasPublishScript?: boolean
@@ -197,6 +198,7 @@ export async function runVersion({
197198
mrTitle = 'Version Packages',
198199
mrTargetBranch = context.ref,
199200
commitMessage = 'Version Packages',
201+
removeSourceBranch = false,
200202
hasPublishScript = false,
201203
}: VersionOptions) {
202204
const currentBranch = context.ref
@@ -305,13 +307,15 @@ ${
305307
finalMrTitle,
306308
{
307309
description: await mrBodyPromise,
310+
removeSourceBranch,
308311
},
309312
)
310313
} else {
311314
console.log(`updating found merge request !${searchResult[0].iid}`)
312315
await api.MergeRequests.edit(context.projectId, searchResult[0].iid, {
313316
title: finalMrTitle,
314317
description: await mrBodyPromise,
318+
removeSourceBranch,
315319
})
316320
}
317321
}

0 commit comments

Comments
 (0)