Skip to content

Commit 260eb1b

Browse files
committed
fix: use the *last* rebase list, instead of the first
a) if the was only 1 rebase, nothing changes b) in other cases i've encountered, using the last rebase always proved better than the 1st one: 1st one would error oftenly; succeeded rarily last one would work just fine but, there's still a lot of testing to do. especially for >2 rebases, since i've only encountered 2. it's a bit dangerous because if we pick the wrong rebase, then we could lose commits / their content. now, picking just 1 rebase is still incomplete -- this fix is just a (seemingly) better heuristic, (!) but eventually we'll need to take into account all of the rebases. there might be ways to eliminate this need, e.g. auto-calling `git-stacked-rebase --apply` in the `post-rewrite` script in the background, but at least for now, don't want to mess with it and would prefer to avoid, until i have done more dog-fooding & encounter more edge-cases & maybe potential solutions/invariants as well. Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent c7a7b64 commit 260eb1b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

reducePath.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ export function combineRewrittenLists(rewrittenListFileContent: string): Combine
307307
}
308308

309309
prev = []
310-
}
310+
}
311+
312+
if (!lastRebaseList) {
313+
throw new Error(`NOT IMPLEMENTED - did not find any "rebase"(s).`)
314+
}
311315

312316
/**
313317
* TODO handle multiple rebases
@@ -317,7 +321,7 @@ export function combineRewrittenLists(rewrittenListFileContent: string): Combine
317321

318322
console.log("mergedReducedRewrittenLists", mergedReducedRewrittenLists)
319323

320-
const combinedRewrittenList = Object.entries(mergedReducedRewrittenLists[0].mapping).map(([k, v]) => k + " " + v).join("\n") + "\n"
324+
const combinedRewrittenList = Object.entries(lastRebaseList.mapping).map(([k, v]) => k + " " + v).join("\n") + "\n"
321325
// fs.writeFileSync("rewritten-list", combinedRewrittenList)
322326

323327
return {

0 commit comments

Comments
 (0)