Happy Commit
Happy Commit is a VS Code extension that makes failed Git pre-commit hooks much more actionable inside the Source Control UI.
Instead of leaving you with a vague Git: precommit failed message, the extension:
- detects likely pre-commit hook failures
- parses common
file:line:column lint output
- writes clickable file links to a dedicated
Happy Commit output channel
- sends parsed issues into the Problems panel as VS Code diagnostics
- lets you jump straight to the first parsed error
- adds a
Commit with Happy Commit Source Control action that can bypass the built-in Git commit popup
- shows a persistent
Happy Commit panel view with grouped file errors
- offers an
Open Error List picker and Retry Commit action after failures
What it does
When a commit fails because of tooling such as Husky, lint-staged, or ESLint, Happy Commit tries to surface the useful part of the failure:
- Notification:
Pre-commit failed: 3 lint errors found
- Actions:
- Problems panel:
- parsed diagnostics grouped by file
- Happy Commit panel:
- persistent tree view grouped by file
- click any issue to open it
- title actions for error list, retry, and clear
- Output channel:
- clickable
path:line:column message entries
- raw Git log snippet for debugging
Commands
The extension contributes these commands:
Happy Commit: Commit with Happy Commit
Happy Commit: Open Error List
Happy Commit: Parse Last Git Errors
Happy Commit: Open Problems
Happy Commit: Open Output
Happy Commit: Open First Error
Happy Commit: Retry Commit
Happy Commit: Clear Diagnostics
Recommended usage
If you want to avoid the built-in Git failure popup, use the Commit with Happy Commit action from the Source Control title area or Command Palette.
That command runs git commit directly from the extension host, captures stdout and stderr itself, and routes failures through the Happy Commit notification, Problems, and Output channel.
If you still commit with the built-in Git commit button, VS Code may show its native failure dialog first. Happy Commit will then try to improve the experience by parsing the Git logs afterward.
Failure UI
When errors are parsed, you have three layers of navigation:
- The failure notification for fast actions
Open opens the error picker first, then falls back to the Happy Commit panel
Open Error List, which shows a Quick Pick of parsed issues
- The
Happy Commit panel view, which keeps the failure visible until the next successful commit or manual clear
The parser handles these common patterns:
Inline file/line/column
src/foo.ts:14:9 Unexpected any
/Users/me/project/src/foo.ts:14:9 Missing return type
src/components/Button.tsx:22:7 'foo' is defined but never used
ESLint stylish-style blocks
src/foo.ts
14:9 error Unexpected any @typescript-eslint/no-explicit-any
20:3 warning 'value' is assigned a value but never used @typescript-eslint/no-unused-vars
How it works
Git integration
The extension attaches to the built-in vscode.git API for:
- repository discovery
- repository selection context
- locating the Git binary path
- commit success detection
- clearing stale diagnostics after successful commits
Commit failure detection
The public Git extension API does not currently expose a stable commit-failure event or a public stream of the raw stderr output for a failed commit when the user commits via the built-in Git UI.
Because of that, Happy Commit uses a best-effort fallback:
- It locates the built-in Git extension log directory when available.
- It tails recent Git log output.
- It extracts the most recent commit-related block.
- It parses lint errors from that block.
This works well for local testing and is the most practical public-API-compatible option today.
If automatic detection misses a failure, run Happy Commit: Parse Last Git Errors.
The Commit with Happy Commit action avoids the built-in popup by not using the built-in Git commit command path.
Instead it:
- Uses
vscode.git to discover the selected repository and Git executable.
- Runs
git commit --file - directly.
- Captures stdout and stderr from the commit process.
- Parses the failure output immediately.
- Shows the Happy Commit notification and diagnostics.
- Keeps the parsed session in the
Happy Commit panel and enables Retry Commit.
Settings
happyCommit.autoOpenFirstError
- Type:
boolean
- Default:
false
When enabled, the extension opens the first parsed error automatically after it detects a pre-commit failure.
Running locally
- Create a new folder and copy these files into it.
- Run:
npm install
npm run compile
- Open the folder in VS Code.
- Press
F5 to launch the Extension Development Host.
- Open a Git repository in the development host and test commits from Source Control.
Publishing
This repo is now set up for Marketplace packaging with:
- a Marketplace icon at
media/icon.png
- a
LICENSE
- a
CHANGELOG.md
- a package allowlist in
package.json
Before you publish, update these values in package.json:
publisher: replace local with your real Marketplace publisher ID
repository, homepage, and bugs: add your real repository URLs if you want a complete listing
Then package or publish with vsce:
vsce package
vsce publish
Testing with Husky, lint-staged, and ESLint
One simple way to test the extension:
- Create a repository with Husky, lint-staged, and ESLint configured for staged files.
- Add a file with a clear lint failure such as:
const value: any = 1;
- Stage the file.
- Attempt a commit from the VS Code Source Control view.
- Confirm that:
- the commit fails
- a Happy Commit notification appears
Open Error List shows a Quick Pick of parsed issues
- the
Happy Commit panel shows grouped file errors
- Problems contains diagnostics
- the
Happy Commit output channel contains clickable file links
Open First Error jumps to the exact location
Retry Commit reruns the last failed commit attempt if you used Commit with Happy Commit
- if you used
Commit with Happy Commit, you do not rely on the built-in Git failure popup
Example flow
- You click Commit in Source Control.
- Husky runs
lint-staged.
- ESLint fails with file/line/column output.
- Happy Commit parses the recent Git output.
- A notification appears with direct actions.
- Problems, Output, and the
Happy Commit panel are updated.
- You click
Open Error List or a tree item and land on the offending file and range.
- After fixing the issue, you click
Retry Commit.
Limitations
- There is no stable public VS Code API for direct Git commit failure callbacks with raw stderr. Automatic failure detection therefore relies on best-effort parsing of the built-in Git extension logs.
- The popup bypass only applies when you use
Commit with Happy Commit. If you use the built-in Git commit button, VS Code may still show its native failure dialog.
- If the built-in Git log format changes in future VS Code releases, the automatic detector may become less accurate until adjusted.
- The parser intentionally focuses on common
file:line:column and ESLint-style output. Extremely custom hook output may require manual inspection in the output channel.
- Clickable links in the Output panel depend on VS Code's own link detection behavior.
Retry Commit reuses the last commit message captured by Happy Commit or, for log-based failures, the current SCM input box value when available.
Known limitations
- Automatic detection may miss some failures if the relevant hook output never reaches the built-in Git logs.
Commit with Happy Commit currently commits staged changes only.
- In multi-repository workspaces, repository root inference is heuristic when the hook output only contains relative paths.
- Some stylish or codeframe formats can be partially parsed but not fully reconstructed if the tool omits file context.