Skip to content

Commit

Permalink
remove the dynamic "rewrittenList" filename - use static one
Browse files Browse the repository at this point in the history
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
  • Loading branch information
kiprasmel committed Apr 10, 2022
1 parent 3c8f248 commit 674169d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
10 changes: 1 addition & 9 deletions branchSequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import assert from "assert";

import Git from "nodegit";

import { filenames } from "./filenames";

import { createExecSyncInRepo } from "./util/execSyncInRepo";
import { Termination } from "./util/error";

Expand Down Expand Up @@ -54,7 +52,6 @@ export type BranchSequencerArgs = BranchSequencerArgsBase & {
actionInsideEachCheckedOutBranch: ActionInsideEachCheckedOutBranch;
delayMsBetweenCheckouts?: number;
callbackAfterDone?: CallbackAfterDone;
rewrittenListFile?: typeof filenames.rewrittenList;
};

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

const stackedRebaseCommandsNew: GoodCommand[] = parseNewGoodCommands(
repo,
pathToStackedRebaseTodoFile,
rewrittenListFile
);
const stackedRebaseCommandsNew: GoodCommand[] = parseNewGoodCommands(repo, pathToStackedRebaseTodoFile);

// const remotes: Git.Remote[] = await repo.getRemotes();
// const remote: Git.Remote | undefined = remotes.find((r) =>
Expand Down
1 change: 0 additions & 1 deletion forcePush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
execSyncInRepo(`${argsBase.gitCmd} push --force`);
},
delayMsBetweenCheckouts: 0,
rewrittenListFile: "rewritten-list.applied",
});
7 changes: 3 additions & 4 deletions parse-todo-of-stacked-rebase/parseNewGoodCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import { GoodCommand, stackedRebaseCommands } from "./validator";

export function parseNewGoodCommands(
repo: Git.Repository,
pathToStackedRebaseTodoFile: string, //
rewrittenListFile: typeof filenames.rewrittenList | typeof filenames.rewrittenListApplied
pathToStackedRebaseTodoFile: string //
): GoodCommand[] {
const oldGoodCommands: GoodCommand[] = parseTodoOfStackedRebase(pathToStackedRebaseTodoFile);

logGoodCmds(oldGoodCommands);

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

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

const [oldSHA, newSHA] = fromToSHA;
Expand Down

0 comments on commit 674169d

Please sign in to comment.