Skip to content

Commit 03b3f54

Browse files
committed
as suspected, autoSquash was meant only for the actual rebase operation
see next commit on how we realized this (hint: current impl is still broken) Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent e49e8b4 commit 03b3f54

File tree

4 files changed

+10
-74
lines changed

4 files changed

+10
-74
lines changed

apply.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ export const apply: BranchSequencerBase = (args) =>
2626
delayMsBetweenCheckouts: 0,
2727
behaviorOfGetBranchBoundaries: BehaviorOfGetBranchBoundaries["parse-from-not-yet-applied-state"],
2828
reverseCheckoutOrder: false,
29-
30-
/**
31-
* `apply` does not perform the rebase operation
32-
* and thus cannot fully modify local commit history,
33-
* thus `autoSquash` is disabled
34-
* (it would produce incorrect results otherwise).
35-
*/
36-
autoSquash: false,
3729
}).then(
3830
(ret) => (markThatApplied(args.pathToStackedRebaseDirInsideDotGit), ret) //
3931
);

branchSequencer.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import assert from "assert";
33

44
import Git from "nodegit";
55

6-
import { AutoSquash, getWantedCommitsWithBranchBoundariesOurCustomImpl } from "./git-stacked-rebase";
6+
import { getWantedCommitsWithBranchBoundariesOurCustomImpl } from "./git-stacked-rebase";
77

88
import { createExecSyncInRepo } from "./util/execSyncInRepo";
99
import { Termination } from "./util/error";
@@ -23,7 +23,6 @@ export type GetBranchesCtx = BranchRefs & {
2323
rootLevelCommandName: string;
2424
repo: Git.Repository;
2525
pathToStackedRebaseTodoFile: string;
26-
autoSquash: boolean;
2726
};
2827
export type SimpleBranchAndCommit = {
2928
commitSHA: string | null;
@@ -118,8 +117,7 @@ const getBoundariesInclInitialWithSipleBranchTraversal: GetBoundariesInclInitial
118117
getWantedCommitsWithBranchBoundariesOurCustomImpl(
119118
argsBase.repo, //
120119
argsBase.initialBranch,
121-
argsBase.currentBranch,
122-
argsBase.autoSquash
120+
argsBase.currentBranch
123121
).then((boundaries) =>
124122
boundaries
125123
.filter((b) => !!b.branchEnd?.length)
@@ -242,14 +240,6 @@ export type BranchSequencerArgs = BranchSequencerArgsBase & {
242240
*
243241
*/
244242
reverseCheckoutOrder: boolean;
245-
246-
/**
247-
* almost feels like it should default to `false`,
248-
* or even shouldn't be selectable here & always be `false`.
249-
*
250-
* TODO further investigation
251-
*/
252-
autoSquash: AutoSquash;
253243
};
254244

255245
export type BranchSequencerBase = (args: BranchSequencerArgsBase) => Promise<void>;
@@ -270,8 +260,6 @@ export const branchSequencer: BranchSequencer = async ({
270260
currentBranch,
271261
//
272262
reverseCheckoutOrder = false,
273-
//
274-
autoSquash,
275263
}) => {
276264
const execSyncInRepo = createExecSyncInRepo(repo);
277265

@@ -288,7 +276,6 @@ export const branchSequencer: BranchSequencer = async ({
288276
rootLevelCommandName,
289277
initialBranch,
290278
currentBranch,
291-
autoSquash,
292279
})
293280
).map((boundary) => {
294281
boundary.branchEndFullName = boundary.branchEndFullName.map((x) => x.replace("refs/heads/", ""));

forcePush.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,4 @@ export const forcePush: BranchSequencerBase = (argsBase) =>
133133
* would solve this.
134134
*/
135135
reverseCheckoutOrder: true,
136-
137-
/**
138-
* `forcePush` does not perform the rebase operation
139-
* and thus cannot fully modify local commit history,
140-
* thus `autoSquash` is disabled
141-
* (it would produce incorrect results otherwise).
142-
*/
143-
autoSquash: false,
144136
});

git-stacked-rebase.ts

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -416,17 +416,6 @@ export const gitStackedRebase = async (
416416
"if-stacked-rebase-in-progress-then-parse-not-applied-state-otherwise-simple-branch-traverse"
417417
],
418418
reverseCheckoutOrder: false,
419-
420-
/**
421-
* `branchSequencer` does not perform the rebase operation
422-
* and thus cannot fully modify local commit history,
423-
* thus `autoSquash` is disabled
424-
* (it would produce incorrect results otherwise).
425-
*
426-
* TODO further investigation
427-
*
428-
*/
429-
autoSquash: false,
430419
});
431420
} else {
432421
/**
@@ -976,31 +965,17 @@ export function removeUndefinedProperties<T, K extends keyof Partial<T>>(
976965
);
977966
}
978967

979-
/**
980-
* should commits with "squash!" and "fixup!" subjects be autosquashed.
981-
*
982-
* if an actual rebase operation is NOT being performed
983-
* (i.e. commits are not being rewritten),
984-
* then SHALL BE set to `false`.
985-
*
986-
* otherwise, should be configured in some way -- most likely
987-
* via the git config, and/or the CLI.
988-
*
989-
*/
990-
export type AutoSquash = boolean;
991-
992968
async function createInitialEditTodoOfGitStackedRebase(
993969
repo: Git.Repository, //
994970
initialBranch: Git.Reference,
995971
currentBranch: Git.Reference,
996972
pathToRebaseTodoFile: string,
997-
autoSquash: AutoSquash,
973+
autoSquash: boolean,
998974
getCommitsWithBranchBoundaries: () => Promise<CommitAndBranchBoundary[]> = () =>
999975
getWantedCommitsWithBranchBoundariesOurCustomImpl(
1000976
repo, //
1001977
initialBranch,
1002-
currentBranch,
1003-
autoSquash
978+
currentBranch
1004979
)
1005980
): Promise<void> {
1006981
// .catch(logErr);
@@ -1027,6 +1002,10 @@ async function createInitialEditTodoOfGitStackedRebase(
10271002

10281003
noop(commitsWithBranchBoundaries);
10291004

1005+
if (autoSquash) {
1006+
await autosquash(repo, commitsWithBranchBoundaries);
1007+
}
1008+
10301009
const rebaseTodo = commitsWithBranchBoundaries
10311010
.map(({ commit, commitCommand, branchEnd }, i) => {
10321011
if (i === 0) {
@@ -1147,8 +1126,7 @@ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl(
11471126
repo: Git.Repository, //
11481127
/** beginningBranch */
11491128
bb: Git.Reference,
1150-
currentBranch: Git.Reference,
1151-
autoSquash: boolean
1129+
currentBranch: Git.Reference
11521130
): Promise<CommitAndBranchBoundary[]> {
11531131
/**
11541132
* BEGIN check e.g. fork & origin/fork
@@ -1215,20 +1193,7 @@ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl(
12151193
)
12161194
);
12171195

1218-
const extended: CommitAndBranchBoundary[] = await extendCommitsWithBranchEnds(
1219-
repo,
1220-
bb,
1221-
currentBranch,
1222-
wantedCommits
1223-
);
1224-
1225-
if (!autoSquash) {
1226-
return extended;
1227-
}
1228-
1229-
await autosquash(repo, extended);
1230-
1231-
return extended;
1196+
return extendCommitsWithBranchEnds(repo, bb, currentBranch, wantedCommits);
12321197
}
12331198

12341199
noop(getWantedCommitsWithBranchBoundariesUsingNativeGitRebase);

0 commit comments

Comments
 (0)