Last active
May 21, 2024 08:12
-
-
Save scarf005/baf2e6de9f1cfcad47a56a00f6e58feb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sync PR/revert인 경우 merge commit, 그 외에는 squash merge | |
* | |
* 의존성: [github cli](https://cli.github.com) | |
* 설치: gh alias set pr-merge '! deno run -A /스크립트가/있는/경로/gh-pr-merge.ts $@' | |
* | |
* @module | |
*/ | |
import $ from "jsr:@david/dax@^0.41.0" | |
const target = Deno.args[0] ?? "" | |
const { headRefName } = await $`gh pr view ${target} --json headRefName` | |
.json<{ headRefName: string }>() | |
const shouldMerge = /sync|revert/.test(headRefName) | |
const mergeMethod = shouldMerge ? "--merge" : "--squash" | |
if (Deno.env.get("DEBUG")) { | |
console.log({ target, headRefName, shouldMerge, mergeMethod }) | |
} | |
const ok = shouldMerge | |
? await $.confirm("will run regular merge", { default: false }) | |
: true | |
if (!ok) throw new Error("cancelled") | |
await $`gh pr merge ${target} --delete-branch ${mergeMethod}`.printCommand() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment