Skip to content

Commit fa58ac5

Browse files
committed
get rid of the .applied stuff; needs more verification though
Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent 0331bb5 commit fa58ac5

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

branchSequencer.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import assert from "assert";
33

44
import Git from "nodegit";
55

6-
import { filenames } from "./filenames";
7-
86
import { createExecSyncInRepo } from "./util/execSyncInRepo";
97
import { Termination } from "./util/error";
108

@@ -54,7 +52,6 @@ export type BranchSequencerArgs = BranchSequencerArgsBase & {
5452
actionInsideEachCheckedOutBranch: ActionInsideEachCheckedOutBranch;
5553
delayMsBetweenCheckouts?: number;
5654
callbackAfterDone?: CallbackAfterDone;
57-
rewrittenListFile?: typeof filenames.rewrittenList;
5855
};
5956

6057
export type BranchSequencerBase = (args: BranchSequencerArgsBase) => Promise<void>;
@@ -70,17 +67,13 @@ export const branchSequencer: BranchSequencer = async ({
7067
// callbackBeforeBegin,
7168
actionInsideEachCheckedOutBranch,
7269
callbackAfterDone = (): void => {},
73-
rewrittenListFile = filenames.rewrittenList,
70+
gitCmd,
7471
}) => {
7572
if (!fs.existsSync(pathToStackedRebaseDirInsideDotGit)) {
7673
throw new Termination(`\n\nno stacked-rebase in progress? (nothing to ${rootLevelCommandName})\n\n`);
7774
}
7875

79-
const stackedRebaseCommandsNew: GoodCommand[] = parseNewGoodCommands(
80-
repo,
81-
pathToStackedRebaseTodoFile,
82-
rewrittenListFile
83-
);
76+
const stackedRebaseCommandsNew: GoodCommand[] = parseNewGoodCommands(repo, pathToStackedRebaseTodoFile);
8477

8578
// const remotes: Git.Remote[] = await repo.getRemotes();
8679
// const remote: Git.Remote | undefined = remotes.find((r) =>
@@ -157,8 +150,11 @@ export const branchSequencer: BranchSequencer = async ({
157150
*/
158151
const isFinalCheckout: boolean = cmds.length === 1;
159152

153+
/**
154+
* https://libgit2.org/libgit2/#HEAD/group/checkout/git_checkout_head
155+
*/
160156
// await Git.Checkout.tree(repo, targetBranch as any); // TODO TS FIXME
161-
execSyncInRepo(`git checkout ${targetBranch}`); // f this
157+
execSyncInRepo(`${gitCmd} checkout ${targetBranch}`); // f this
162158

163159
await actionInsideEachCheckedOutBranch({
164160
repo, //

forcePush.ts

-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
3838
execSyncInRepo(`${argsBase.gitCmd} push --force`);
3939
},
4040
delayMsBetweenCheckouts: 0,
41-
rewrittenListFile: "rewritten-list.applied",
4241
});

git-stacked-rebase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ export const gitStackedRebase = async (
351351

352352
console.log({ commitShaOfInitialBranch });
353353

354-
await repo.checkoutRef(initialBranch);
354+
await repo.checkoutRef(initialBranch); /** TODO wtf */
355355
// repo.rebaseBranches()
356356

357357
// const headName: string = (await (await repo.getHeadCommit()).sha()) + "\n";

parse-todo-of-stacked-rebase/parseNewGoodCommands.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ import { GoodCommand, stackedRebaseCommands } from "./validator";
1414

1515
export function parseNewGoodCommands(
1616
repo: Git.Repository,
17-
pathToStackedRebaseTodoFile: string, //
18-
rewrittenListFile: typeof filenames.rewrittenList | typeof filenames.rewrittenListApplied
17+
pathToStackedRebaseTodoFile: string //
1918
): GoodCommand[] {
2019
const goodCommands: GoodCommand[] = parseTodoOfStackedRebase(pathToStackedRebaseTodoFile);
2120

2221
logGoodCmds(goodCommands);
2322

24-
const pathOfRewrittenList: string = path.join(repo.workdir(), ".git", "stacked-rebase", rewrittenListFile);
23+
const pathOfRewrittenList: string = path.join(repo.workdir(), ".git", "stacked-rebase", filenames.rewrittenList);
2524
const rewrittenList: string = fs.readFileSync(pathOfRewrittenList, { encoding: "utf-8" });
2625
const rewrittenListLines: string[] = rewrittenList.split("\n").filter((line) => !!line);
2726

@@ -36,7 +35,7 @@ export function parseNewGoodCommands(
3635
const fromToSHA = line.split(" ");
3736
assert(
3837
fromToSHA.length === 2,
39-
`from and to SHAs, coming from ${rewrittenListFile}, are written properly (1 space total).`
38+
`from and to SHAs, coming from ${filenames.rewrittenList}, are written properly (1 space total).`
4039
);
4140

4241
const [oldSHA, newSHA] = fromToSHA;

0 commit comments

Comments
 (0)