Wrong error message extraction when Git hooks fail
Does this issue occur when all extensions are disabled?: Yes
Version: 1.106.3 (system setup) Commit: bf9252a2fb45be6893dd8870c0bf37e2e1766d61 Date: 2025-11-25T22:28:18.024Z Electron: 37.7.0 ElectronBuildId: 12781156 Chromium: 138.0.7204.251 Node.js: 22.20.0 V8: 13.8.258.32-electron.0 OS: Windows_NT x64 10.0.26200
Problem Description
When Git hooks (e.g., pre-commit hooks) fail, VS Code displays misleading error messages. The error message extraction logic simply takes the first line of the hook output, which may be an informational or success message rather than the actual error. This makes it difficult for users to understand why their commit failed.
Expected Behavior
When a Git hook fails, VS Code should display the actual error message that explains why the hook failed, prioritizing lines that indicate failures (e.g., "Failed", "exit code", "hook id:") over informational or success messages.
Actual Behavior
VS Code shows the first line of the hook output as the error message, which could be:
- A success message (e.g., "Passed", "Skipped", "no files to check")
- An informational message that doesn't explain the actual failure
- A message from a different hook that passed, while the actual failure is on a later line
This causes confusion as users see messages like "Git: Passed" or "Git: no files to check" when their commit actually failed due to a different hook.
Steps to Reproduce
- Set up a Git repository with multiple pre-commit hooks (e.g., using Husky or similar tools)
- Configure one hook to pass and another to fail
- Attempt to commit changes in VS Code
- Observe the error message displayed
Example scenario:
- Create a pre-commit hook that runs linting
- The linting hook outputs: "Passed: ESLint check" on the first line, but a later hook fails with "Failed: Unit tests"
- VS Code shows: "Git: Passed: ESLint check" instead of the actual failure