Uses correct counts in rebase command condition/messaging#3780
Conversation
Updates property names to be clearer
| createRevisionRange(state.destination.ref, context.branch.ref, '...'), | ||
| { excludeMerges: true }, | ||
| ); | ||
|
|
||
| const title = `${context.title} ${getReferenceLabel(state.reference, { icon: false, label: false })}`; | ||
| const count = counts != null ? counts.left : 0; | ||
| if (count === 0) { | ||
| const title = `${context.title} ${getReferenceLabel(state.destination, { icon: false, label: false })}`; | ||
| const ahead = counts != null ? counts.right : 0; | ||
| const behind = counts != null ? counts.left : 0; |
There was a problem hiding this comment.
The core of the bug lies in these lines. The ref that is passed into the rebase command via state is the destination of the rebase, not the source. The rebase command is rebasing the current branch (previously housed in context.destination, renamed now to context.branch onto the chosen branch (previously housed in state.reference, renamed here to state.destination).
When we get the counts in container.git.getLeftRightCommitCount, we consistently put the "destination" on the left of the git revision range. In this case, because of the mislabeling, we were putting the source (current branch) on the left side and calling it the "destination", and the actual destination (chosen branch) is on the right side. So counts.left was giving us "how many commits ahead the current branch is" when we really wanted to know "how many commits behind the current branch is". In the messaging further down though, we say "will rebase by applying X commits on top of". Here, we want to know "how many commits ahead the current branch is".
So I split the counts into clearly labeled ahead and behind variables, put the "destination" and "source" into the correct slots of the revision range, and renamed everywhere so that it's clear that the destination is the argument provided to the command in the state/initial state, and the source is the current branch that we load into the context.
* Uses correct counts in rebase condition/messaging Updates property names to be clearer * Updates placeholder wording
Fixes #3747
Updates property names to be clearer in rebase command, and uses the correct side of the left-right commit count to:
Repro steps:
Choose a rebase command: "rebase current branch onto branch", "rebase current branch onto tip", or "GitLens: Git Rebase" command palette command.
Before: Quickpick prevents rebase and states that the current branch is already up-to-date with the destination when it is not. After: Quickpick should allow the rebase, and give the correct number of commits that will be rebased on top of the destination.