-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: commit stacking #2869
base: main
Are you sure you want to change the base?
feat: commit stacking #2869
Conversation
43b0a5d
to
11c432d
Compare
This feature introduces a useful way to checkout commits when performing code review or browsing large repository, called 'commit stacking'. The idea is to add a stack of Commit. The user can push and pop commits to this stack as they jump around the code. When the user pops the entire stack Gitlens restores the repository to the ref that was checked out before the first push of a commit. To accomplish this three new commands were added: 'switchToCommitStacked': accessible from the right click context menu in the commit's view. this pushes the selected commit onto the stack and checks the repository out to it. 'switchToCommitPop' - accessible from the navigation menu in the commits view. this pops the top commit from the stack and checks out the new head of the stack. 'commitStackEmpty' - accessible from the command pallete. this is a shortcut to immediately clear the stack and check out the original ref before the first commit was pushed to the stack. Additionally, a status bar item is created when the stack has items on it. This format is `commit stack: ${curNode.ref.name} ${this.commitStack.length}` where curNode is a ViewRefNode. The reason this feature is rather useful is because LSP tools do not work when viewing diffs spawned from commits. Instead, VSCode opens read only editors where you can no longer navigate code with the LSP. Even if the diff editor is not read only, some LSP's simply won't work in this view. By supporting `commit stacking` a user can quickly jump to a commit, navigate it with their LSP tools, and hop right back to where they were. Additionally, the user can make arbitrary jumps between commits without having to keep a list of which commits they jumped between. Signed-off-by: Louis DeLosSantos <[email protected]>
11c432d
to
6497549
Compare
Thank you for your efforts here! Can you help me understand the workflow that this enables? I can understand the desire to checkout to a specific commit for LSP to work properly, but why the stacking? What is the workflow to toggle back and forth? |
Thanks a lot for your attention. So the workflow I was trying to solve here was this scenario.
The reason this 'memory' of the stack is useful is become
If this feature is supported, I'd also like to nicely support a way to automatically add multiple commits to the stack to support this workflow
Those are my end goals with this. Very happy to get opinions and understand if this is a bit too contrived for the Gitlens project, I can always maintain fork :). But if you see usefulness in this idea i'm welcome to massaging it to something you agree with. |
Description
This feature introduces a useful way to checkout commits when performing code review or browsing large repository, called 'commit stacking'.
The idea is to add a stack of Commit.
The user can push and pop commits to this stack as they jump around the code.
When the user pops the entire stack Gitlens restores the repository to the ref that was checked out before the first push of a commit.
To accomplish this three new commands were added:
'switchToCommitStacked':
accessible from the right click context menu in the commit's view. this pushes the selected commit onto the stack and checks the repository out to it.
'switchToCommitPop' -
accessible from the navigation menu in the commits view. this pops the top commit from the stack and checks out the new head of the stack.
'commitStackEmpty' -
accessible from the command pallete.
this is a shortcut to immediately clear the stack and check out the original ref before the first commit was pushed to the stack.
Additionally, a status bar item is created when the stack has items on it.
This format is
commit stack: ${curNode.ref.name} ${this.commitStack.length}
where curNode is a ViewRefNode.The reason this feature is rather useful is because LSP tools do not work when viewing diffs spawned from commits. Instead, VSCode opens read only editors where you can no longer navigate code with the LSP. Even if the diff editor is not read only, some LSP's simply won't work in this view.
By supporting
commit stacking
a user can quickly jump to a commit, navigate it with their LSP tools, and hop right back to where they were. Additionally, the user can make arbitrary jumps between commits without having to keep a list of which commits they jumped between.Demo
https://github.com/gitkraken/vscode-gitlens/assets/5642902/7ff7339b-7f4d-44a6-b952-470b90d57099
Issue created: #2868
Checklist
Fixes $XXX -
orCloses #XXX -
prefix to auto-close the issue that your PR addresses