Skip to content

Commit c96ff8d

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 <[email protected]>
1 parent 14b02ca commit c96ff8d

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
@@ -307,17 +307,6 @@ export const gitStackedRebase = async (
307307
"if-stacked-rebase-in-progress-then-parse-not-applied-state-otherwise-simple-branch-traverse"
308308
],
309309
reverseCheckoutOrder: false,
310-
311-
/**
312-
* `branchSequencer` does not perform the rebase operation
313-
* and thus cannot fully modify local commit history,
314-
* thus `autoSquash` is disabled
315-
* (it would produce incorrect results otherwise).
316-
*
317-
* TODO further investigation
318-
*
319-
*/
320-
autoSquash: false,
321310
});
322311
} else {
323312
/**
@@ -862,31 +851,17 @@ export function removeUndefinedProperties<T, K extends keyof Partial<T>>(
862851
);
863852
}
864853

865-
/**
866-
* should commits with "squash!" and "fixup!" subjects be autosquashed.
867-
*
868-
* if an actual rebase operation is NOT being performed
869-
* (i.e. commits are not being rewritten),
870-
* then SHALL BE set to `false`.
871-
*
872-
* otherwise, should be configured in some way -- most likely
873-
* via the git config, and/or the CLI.
874-
*
875-
*/
876-
export type AutoSquash = boolean;
877-
878854
async function createInitialEditTodoOfGitStackedRebase(
879855
repo: Git.Repository, //
880856
initialBranch: Git.Reference,
881857
currentBranch: Git.Reference,
882858
pathToRebaseTodoFile: string,
883-
autoSquash: AutoSquash,
859+
autoSquash: boolean,
884860
getCommitsWithBranchBoundaries: () => Promise<CommitAndBranchBoundary[]> = () =>
885861
getWantedCommitsWithBranchBoundariesOurCustomImpl(
886862
repo, //
887863
initialBranch,
888-
currentBranch,
889-
autoSquash
864+
currentBranch
890865
)
891866
): Promise<void> {
892867
// .catch(logErr);
@@ -913,6 +888,10 @@ async function createInitialEditTodoOfGitStackedRebase(
913888

914889
noop(commitsWithBranchBoundaries);
915890

891+
if (autoSquash) {
892+
await autosquash(repo, commitsWithBranchBoundaries);
893+
}
894+
916895
const rebaseTodo = commitsWithBranchBoundaries
917896
.map(({ commit, commitCommand, branchEnd }, i) => {
918897
if (i === 0) {
@@ -1033,8 +1012,7 @@ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl(
10331012
repo: Git.Repository, //
10341013
/** beginningBranch */
10351014
bb: Git.Reference,
1036-
currentBranch: Git.Reference,
1037-
autoSquash: boolean
1015+
currentBranch: Git.Reference
10381016
): Promise<CommitAndBranchBoundary[]> {
10391017
/**
10401018
* BEGIN check e.g. fork & origin/fork
@@ -1101,20 +1079,7 @@ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl(
11011079
)
11021080
);
11031081

1104-
const extended: CommitAndBranchBoundary[] = await extendCommitsWithBranchEnds(
1105-
repo,
1106-
bb,
1107-
currentBranch,
1108-
wantedCommits
1109-
);
1110-
1111-
if (!autoSquash) {
1112-
return extended;
1113-
}
1114-
1115-
await autosquash(repo, extended);
1116-
1117-
return extended;
1082+
return extendCommitsWithBranchEnds(repo, bb, currentBranch, wantedCommits);
11181083
}
11191084

11201085
noop(getWantedCommitsWithBranchBoundariesUsingNativeGitRebase);

0 commit comments

Comments
 (0)