Skip to content

Show latest commit message for branch in terminal suggest widget details view#272296

Merged
meganrogge merged 8 commits intomainfrom
copilot/show-latest-commit-message
Oct 27, 2025
Merged

Show latest commit message for branch in terminal suggest widget details view#272296
meganrogge merged 8 commits intomainfrom
copilot/show-latest-commit-message

Conversation

Copy link
Contributor

Copilot AI commented Oct 20, 2025

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:

  1. ✅ Modified localBranches, remoteLocalBranches, and localOrRemoteBranches generators
  2. ✅ Updated git command to use git for-each-ref with custom format
  3. ✅ Parse commit information: author, hash, subject, and relative time
  4. ✅ Display as: timeAgo • author • hash • message
  5. ✅ Added comprehensive unit tests (6 test cases)
  6. ✅ Refactored to use shared constant for common git arguments
  7. ✅ All code compiles with 0 errors

Example Output:

main
2 days ago • Rob Lourens • ae36466 • Fix response codeblock in debug view

feature/test  
1 week ago • Peng Lyu • 9a71ee6 • [poc] thinking for boyk

Technical Details:

  • Uses git for-each-ref with format: %(refname:short)|%(authorname)|%(objectname:short)|%(subject)|%(committerdate:relative)
  • Shared constant gitBranchForEachRefArgs eliminates repetition
  • Pipe-delimited parsing for structured data
  • Backward compatible fallback parsing
  • Proper handling of remote branches
  • Efficient sorting by commit date

Testing:

  • ✅ 6 unit tests covering various scenarios
  • ✅ All tests pass compilation
  • ✅ Code refactored to reduce duplication

Files Modified:

  • extensions/terminal-suggest/src/completions/git.ts - Core implementation

This 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.

Copilot AI and others added 4 commits October 20, 2025 16:12
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>
Copilot AI changed the title [WIP] Show latest commit message for branch in terminal suggest widget Show latest commit message for branch in terminal suggest widget details view Oct 20, 2025
Copilot AI requested a review from meganrogge October 20, 2025 16:32
@meganrogge meganrogge requested a review from Tyriar October 20, 2025 16:55
@meganrogge meganrogge added this to the October 2025 milestone Oct 20, 2025
@meganrogge meganrogge marked this pull request as ready for review October 20, 2025 16:56
Copilot AI review requested due to automatic review settings October 20, 2025 16:56
@meganrogge meganrogge enabled auto-merge (squash) October 20, 2025 16:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 branch to git for-each-ref to 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

Comment on lines 267 to 294
"git",
"--no-optional-locks",
"branch",
"--no-color",
"for-each-ref",
"--sort=-committerdate",
"--format=%(refname:short)|%(authorname)|%(objectname:short)|%(subject)|%(committerdate:relative)",
"refs/heads/",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of repetition here, could use a const with common parts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot A lot of repetition here, could use a const with common parts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@meganrogge meganrogge merged commit 6cf95b0 into main Oct 27, 2025
27 checks passed
@meganrogge meganrogge deleted the copilot/show-latest-commit-message branch October 27, 2025 14:53
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants