Skip to content

Feat (PR): Commit Stacking #2868

@ldelossa

Description

@ldelossa

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.

Initial implementation: #2869 - very open to opinions and review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNeeds to be looked at

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions