Skip to content

Commit 563c07f

Browse files
committed
fix: add the removeSourceBranch flag to merge requests to prevent duplicate branches
fix: make checkout message check for general
1 parent d7651b5 commit 563c07f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/gitUtils.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ export const pushTags = async () => {
3737
}
3838

3939
export const switchToMaybeExistingBranch = async (branch: string) => {
40-
const { stderr } = await execWithOutput('git', ['checkout', branch], {
40+
const { stdout, stderr } = await execWithOutput('git', ['checkout', branch], {
4141
ignoreReturnCode: true,
4242
})
43-
const isCreatingBranch = !stderr
44-
.toString()
45-
.includes(`Switched to a new branch '${branch}'`)
46-
if (isCreatingBranch) {
43+
44+
const shouldCreateBranch = !(
45+
stderr.toString().includes(`Switched to`) ||
46+
stdout.toString().includes(`Switched to`)
47+
)
48+
49+
if (shouldCreateBranch) {
4750
await exec('git', ['checkout', '-b', branch])
4851
}
4952
}

src/run.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,14 @@ ${
298298
finalMrTitle,
299299
{
300300
description: await mrBodyPromise,
301+
removeSourceBranch: true,
301302
},
302303
)
303304
} else {
304305
await api.MergeRequests.edit(context.projectId, searchResult[0].iid, {
305306
title: finalMrTitle,
306307
description: await mrBodyPromise,
308+
removeSourceBranch: true,
307309
})
308310
console.log('merge request found')
309311
}

0 commit comments

Comments
 (0)