Add pre-merge validation in mergeAndClose
This commit is contained in:
parent
bcca8808f3
commit
920b4d12b4
|
|
@ -93,6 +93,11 @@ export async function resolveConflicts(
|
||||||
/** Merge (or squash-merge) a branch into main, resolve conflicts if needed, and close the session. */
|
/** Merge (or squash-merge) a branch into main, resolve conflicts if needed, and close the session. */
|
||||||
export async function mergeAndClose(branch: string, opts?: { squash?: boolean }): Promise<void> {
|
export async function mergeAndClose(branch: string, opts?: { squash?: boolean }): Promise<void> {
|
||||||
const root = await git.repoRoot()
|
const root = await git.repoRoot()
|
||||||
|
const main = await git.mainBranch(root)
|
||||||
|
const current = await git.currentBranch(root)
|
||||||
|
if (current !== main) {
|
||||||
|
die(`You must be on "${main}" to merge. Currently on "${current}".`)
|
||||||
|
}
|
||||||
const session = await state.getSession(root, branch)
|
const session = await state.getSession(root, branch)
|
||||||
|
|
||||||
if (session && await git.isDirty(session.worktree)) {
|
if (session && await git.isDirty(session.worktree)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user