Commit Line
A tiny VS Code extension that shows the last commit for the line your cursor is on — just like GitLens's "current line blame", and nothing else.
const x = doThing(); You, 3 days ago • Fix parser bug
- Inline annotation at the end of the cursor's line: author, relative time, commit subject.
- Hover any line for the full details: commit subject + body, author + email, full date, and the complete commit hash.
- Bitbucket links in the hover: Copy PR link, Open PR, and Copy commit link (clickable buttons).
- Works on unsaved buffers (it blames the in-editor content), so edited lines show as Uncommitted changes.
Settings
| Setting |
Default |
Description |
commitLine.enabled |
true |
Show the inline annotation. Renders as a checkbox in the Settings UI. Toggle quickly with the Commit Line: Toggle Inline Blame command. |
commitLine.bitbucketBaseUrl |
"" |
Web base URL of a self-hosted Bitbucket Server (e.g. https://git.example.com). Set this when your server's hostname isn't auto-detected — a custom domain without "bitbucket", no /scm/ path, and not on SSH port 7999. Links are built from this URL when its host matches your origin remote. |
Bitbucket pull-request links
The hover offers buttons that copy/open the Bitbucket PR and commit URLs.
No API token is needed — everything is derived locally:
- The repo's base URL comes from
git remote get-url origin. Both Cloud
(bitbucket.org/{workspace}/{repo}) and Server / Data Center
({host}/projects/{PROJECT}/repos/{repo}) are detected automatically.
- The PR number is read from the commit message: Bitbucket stamps
(pull request #N) into squash commits and into merge commits. For
merge-commit workflows the extension walks to the nearest merge commit that
brought the line's commit into the branch.
- Caveat: fast-forward / rebase merges that leave no PR reference in any
commit message can't be resolved to a PR — in that case only the commit
link is shown (it's always constructible). Non-Bitbucket remotes show no link
buttons.
Develop / run it
npm install
npm run compile # or: npm run watch
Then press F5 in VS Code to launch an Extension Development Host with the
extension loaded. Open any file inside a git repository and move your cursor.
Commands
- Commit Line: Toggle Inline Blame — turn the inline annotation on/off.
- Commit Line: Show Log — open the Commit Line Output channel.
- Commit Line: Run Diagnostics — probe everything for the current file/line and dump the result to the Output channel (see below).
Debugging a deployment
If the extension is deployed somewhere you can't iterate quickly (e.g. a VDI),
use the built-in diagnostics instead of guessing:
- Make sure
commitLine.debug is true (it is by default).
- Open a file in your repo and click a committed line.
- Run Commit Line: Run Diagnostics from the Command Palette (
Ctrl/Cmd+Shift+P).
- Open View → Output, pick Commit Line from the dropdown, select all, copy.
The log reports, step by step: whether git is found, whether you're inside a
repo, the origin remote URL, how it was parsed into Bitbucket links, the blame
result for the line, and the resolved PR number (and from where). A common VDI
failure is git executable not found on PATH — the log calls that out explicitly.
The log may contain internal hostnames and file paths; sanitize before sharing
if needed.
Package as a .vsix (optional)
npx @vscode/vsce package
Install the resulting .vsix with Extensions: Install from VSIX… or:
code --install-extension commit-line-0.0.1.vsix
How it works
On cursor move (debounced ~200ms) it runs git blame --porcelain -L <line>,<line>
for the current line, feeding the live buffer via --contents -, and renders the
result as an editor decoration. Hovers lazily fetch the full commit message via
git show. Blame results are cached per file version + line.