vscode-pull-request-github icon indicating copy to clipboard operation
vscode-pull-request-github copied to clipboard

Link commit SHAs in inline file comments

Open Copilot opened this issue 2 months ago • 0 comments

Commit SHAs referenced in PR comments appear as plain text in the file view, while they're correctly hyperlinked in the PR description view.

Root cause: PR description uses GitHub's pre-processed bodyHTML containing SHA links. File view comments process raw markdown through GHPRComment.replaceBody(), which lacked SHA detection.

Changes:

  • Added COMMIT_SHA_EXPRESSION regex to match 7 or 40-char hexadecimal SHAs
  • Implemented replaceCommitShas() in GHPRComment to convert SHAs to markdown links
  • Integrated into replaceBody() transformation pipeline
  • Exported constant and added test coverage

Pattern matching:

// Matches: "Fixed in 5cf56bc" → "[5cf56bc](https://github.com/owner/repo/commit/5cf56bc)"
// Skips: URLs, code blocks (`abc1234`), markdown links, non-hex strings
const COMMIT_SHA_EXPRESSION = /(?<![`\/\w])([0-9a-f]{7})([0-9a-f]{33})?(?![`\/\w])/g;

Before: Comment with a commit SHA to test highlighting: 5cf56bc
After: Comment with a commit SHA to test highlighting: 5cf56bc

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: /opt/hostedtoolcache/node/20.19.6/x64/bin/node node ./out/src/test/runTests.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Commit SHAs in PR comments are not highlighted or hyperlinked in the file view</issue_title> <issue_description>Commit SHAs are not highlighted and hyperlinked when comments are rendered in-line in the file viewer.

Image

This works as expected in the PR description view:

Image

  • Extension version: 0.108.0
  • VSCode Version: 1.99.0-insider
  • OS: macOS Sequoia 15.4
  • Repository Clone Configuration (single repository/fork of an upstream repository): Single repository
  • Github Product (Github.com/Github Enterprise version x.x.x): GitHub.com

Steps to Reproduce:

  1. Create a pull request review comment in GitHub which references a commit SHA
  2. Open the PR's description view in VS Code. The SHA is highlighted and hyperlinked to the commit on GitHub.com.
  3. Open the file view in VS Code. The SHA is not highlighted or hyperlinked. </issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes microsoft/vscode-pull-request-github#6795

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Dec 10 '25 14:12 Copilot