Skip to content

Commit

Permalink
fix: use the *last* rebase list, instead of the first
Browse files Browse the repository at this point in the history
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 <kipras@kipras.org>
  • Loading branch information
kiprasmel committed May 8, 2022
1 parent 601b427 commit 3a6a223
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions reducePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ export function combineRewrittenLists(rewrittenListFileContent: string): Combine
}

prev = []
}
}

if (!lastRebaseList) {
throw new Error(`NOT IMPLEMENTED - did not find any "rebase"(s).`)
}

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

console.log("mergedReducedRewrittenLists", mergedReducedRewrittenLists)

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

return {
Expand Down

0 comments on commit 3a6a223

Please sign in to comment.