-
Notifications
You must be signed in to change notification settings - Fork 667
Show commit count as decoration on Commits tree node #7959
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: alexr00 <[email protected]>
Cool! I could try it out if there was a way for me to build or pull down a pre-built VS Code to test. Is that a thing that exists? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andyshinn, not really. But, once the PR is merged then the next day you'll be able to try it out in the pre-release version of the GitHub Pull Request extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, don't use the description of the tree node. Instead use a file decoration.
Co-authored-by: alexr00 <[email protected]>
Done in 861832d. Changed to use a file decoration with badge showing the commit count instead of using the tree node's description property. The implementation:
The decoration will appear as a badge next to the "Commits" label in the tree view, similar to how other decorations work in VS Code (e.g., file status badges). |
Problem
Users working with pull requests often need to know the commit count to perform operations like interactive rebasing (e.g.,
git rebase -i HEAD~<count>
). Previously, this information was not readily visible in the VS Code UI and required expanding the Commits tree node or using external commands.Solution
This PR adds a decoration to the "Commits" tree element in the Pull Request changes tree view that displays the number of commits in the pull request. The commit count is now shown as a badge next to the "Commits" label, making it immediately visible without needing to expand the tree.
Implementation
The implementation uses VS Code's file decoration provider pattern:
URI System: Added a new
CommitsNode
scheme and helper functions (createCommitsNodeUri
,fromCommitsNodeUri
) insrc/common/uri.ts
to create unique URIs for Commits tree nodes that include the PR number and commit count.CommitsNode Updates: Modified
CommitsNode
insrc/view/treeNodes/commitsCategoryNode.ts
to set aresourceUri
property using the new URI helper.Decoration Provider: Created
CommitsDecorationProvider
insrc/view/commitsDecorationProvider.ts
that implements the file decoration provider pattern. It returns a badge with the commit count and a tooltip showing "{count} commits".Registration: Registered the
CommitsDecorationProvider
insrc/extension.ts
alongside other tree decoration providers.This approach follows the same pattern used by other decorations in the extension (file type decorations, comment decorations) and provides clean separation between tree node structure and visual presentation.
Example
Before:
Commits
After:
Commits
with a badge showing5
(where 5 is the number of commits)Fixes #6606
Fixes #5150
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.