Skip to content

Commit e7c79a3

Browse files
committed
feat: make branch-end-new actually do it's job
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent a73d19d commit e7c79a3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

git-stacked-rebase.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,22 @@ export const gitStackedRebase = async (
274274
const [exit, goodCommands] = parseTodoOfStackedRebase(pathToStackedRebaseTodoFile);
275275
if (!goodCommands) return fail(exit);
276276

277-
goodCommands.map((cmd) => {
277+
const proms: Promise<void>[] = goodCommands.map(async (cmd) => {
278278
if (cmd.rebaseKind === "regular") {
279279
regularRebaseTodoLines.push(cmd.fullLine);
280+
} else if (cmd.rebaseKind === "stacked") {
281+
if (cmd.commandName === "branch-end-new") {
282+
const newBranchName: string = cmd.targets![0];
283+
const force: number = 0;
284+
const targetCommitSHA: string = cmd.commitSHAThatBranchPointsTo!;
285+
const targetCommit: Git.Commit = await Git.Commit.lookup(repo, targetCommitSHA);
286+
await Git.Branch.create(repo, newBranchName, targetCommit, force);
287+
}
280288
}
281289
});
282290

291+
await Promise.all(proms);
292+
283293
/**
284294
* libgit2's git rebase is sadly not very powerful
285295
* and quite outdated...

0 commit comments

Comments
 (0)