Do reviews in VSCode comparing branches using its native git source control view.
Example:
main
│
│
┌───x main_ancestor
│ │
│ ▼
branch_commit1 x x main_newcommit
│
▼
branch_commit2 x
As in GitHub pull requests, the branch is compared to main before new commits were added to it (main_ancestor). Said differently, all changes from main_ancestor to branch_commit2 are shown (branch_commit1 + branch_commit2 changes).
Two commands are available:
-
reviews.compare
: compare two branches. You need to provide the branch name you want to compare with main. This command:- fetch and update the two branches (if a remote exists)
- find the branches common ancestor (main_ancestor)
- reset --soft the branch to the common ancestor
- switch to the VSCode source control view
If you want to compare with another branch than main, you can type
{branchName}..{anotherBranchThanMain}
, ex.fix/typo..develop
. The command also stores the branch last commit (branch_commit2) workspace wise so you can come back to it using the reset command. -
reviews.reset
: reset the comparison. Comes back to the branch last commit.
- Reset branch prior to comparing.
- Fix a bug where when comparing twice then resetting, the --hard reset was done on main and thus the commits of the branch added to main.
- Add reviews.reset command.