Skip to content

Commit 7c6d15d

Browse files
committed
fix: create initial gitRebaseTodo _before_ options.push|branchSequencer
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent 75fc9e5 commit 7c6d15d

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

git-stacked-rebase.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,29 @@ export const gitStackedRebase = async (
192192
return;
193193
}
194194

195+
fs.mkdirSync(pathToStackedRebaseDirInsideDotGit, { recursive: true });
196+
197+
const initialBranch: Git.Reference | void = await Git.Branch.lookup(
198+
repo, //
199+
nameOfInitialBranch,
200+
Git.Branch.BRANCH.ALL
201+
);
202+
const currentBranch: Git.Reference = await repo.getCurrentBranch();
203+
204+
const wasRegularRebaseInProgress: boolean = fs.existsSync(pathToRegularRebaseDirInsideDotGit);
205+
// const
206+
207+
console.log({ wasRegularRebaseInProgress });
208+
209+
if (!wasRegularRebaseInProgress) {
210+
await createInitialEditTodoOfGitStackedRebase(
211+
repo, //
212+
initialBranch,
213+
// __default__pathToStackedRebaseTodoFile
214+
pathToStackedRebaseTodoFile
215+
);
216+
}
217+
195218
if (options.push) {
196219
if (!options.forcePush) {
197220
return fail("\npush without --force will fail (since git rebase overrides history).\n\n");
@@ -228,29 +251,6 @@ export const gitStackedRebase = async (
228251
}
229252
}
230253

231-
fs.mkdirSync(pathToStackedRebaseDirInsideDotGit, { recursive: true });
232-
233-
const initialBranch: Git.Reference | void = await Git.Branch.lookup(
234-
repo, //
235-
nameOfInitialBranch,
236-
Git.Branch.BRANCH.ALL
237-
);
238-
const currentBranch: Git.Reference = await repo.getCurrentBranch();
239-
240-
const wasRegularRebaseInProgress: boolean = fs.existsSync(pathToRegularRebaseDirInsideDotGit);
241-
// const
242-
243-
console.log({ wasRegularRebaseInProgress });
244-
245-
if (!wasRegularRebaseInProgress) {
246-
await createInitialEditTodoOfGitStackedRebase(
247-
repo, //
248-
initialBranch,
249-
// __default__pathToStackedRebaseTodoFile
250-
pathToStackedRebaseTodoFile
251-
);
252-
}
253-
254254
if (!wasRegularRebaseInProgress || options.viewTodoOnly) {
255255
if (options.editor instanceof Function) {
256256
await options.editor({ filePath: pathToStackedRebaseTodoFile });

0 commit comments

Comments
 (0)