Show latest commit message for branch in terminal suggest widget details view#272296
Show latest commit message for branch in terminal suggest widget details view#272296meganrogge merged 8 commits intomainfrom
Conversation
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the terminal suggest widget to display rich commit information for git branches. When users select branches in terminal completions, they now see the latest commit's author, hash, message, and relative timestamp instead of just the branch name.
Key changes:
- Modified git commands from
git branchtogit for-each-refto retrieve structured commit metadata - Enhanced branch completion parser to extract and format commit details (author, hash, subject, relative time)
- Added comprehensive unit tests for the new parsing logic
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
extensions/terminal-suggest/src/completions/git.ts |
Updated git commands to use for-each-ref with custom format, enhanced postProcessBranches to parse pipe-delimited commit metadata |
extensions/terminal-suggest/src/test/completions/git-branch.test.ts |
Added unit tests covering normal parsing, remote branches, HEAD filtering, empty input, error handling, and deduplication |
| "git", | ||
| "--no-optional-locks", | ||
| "branch", | ||
| "--no-color", | ||
| "for-each-ref", | ||
| "--sort=-committerdate", | ||
| "--format=%(refname:short)|%(authorname)|%(objectname:short)|%(subject)|%(committerdate:relative)", | ||
| "refs/heads/", |
There was a problem hiding this comment.
A lot of repetition here, could use a const with common parts?
There was a problem hiding this comment.
@copilot A lot of repetition here, could use a const with common parts
There was a problem hiding this comment.
Refactored to use a shared constant gitBranchForEachRefArgs for the common git command arguments and format string. This eliminates the repetition across localBranches, remoteLocalBranches, and localOrRemoteBranches generators.
Changes in commit 59a26f6.
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Summary: Show Latest Commit Message for Branches in Terminal Suggest Widget
This PR implements the feature request from issue #256713 to display commit details for branches in the terminal suggest widget.
✅ Implementation Complete
Changes Made:
localBranches,remoteLocalBranches, andlocalOrRemoteBranchesgeneratorsgit for-each-refwith custom formattimeAgo • author • hash • messageExample Output:
Technical Details:
git for-each-refwith format:%(refname:short)|%(authorname)|%(objectname:short)|%(subject)|%(committerdate:relative)gitBranchForEachRefArgseliminates repetitionTesting:
Files Modified:
extensions/terminal-suggest/src/completions/git.ts- Core implementationThis implementation matches the behavior shown in the issue screenshots and provides users with helpful context about branches when using git completions in the terminal.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.