Skip to content

Conversation

@fabio-andre-rodrigues
Copy link

Summary

This PR improves the error message handling in the Git extension to better extract and display meaningful error messages when Git hooks fail. Previously, the code would simply take the first line of the error output, which could result in showing informational or success messages as errors.

Address Bug Report

282523

Changes

  • Enhanced error message extraction logic to prioritize actual error messages over informational messages
  • Added intelligent filtering to identify lines indicating failures (e.g., "Failed", "exit code", "hook id")
  • Added filtering to exclude success/skip messages (e.g., "Passed", "Skipped", "no files to check")
  • Falls back to a generic "Git error" message when only success-related messages are found, preventing misleading error displays

Technical Details

The changes are in the CommandCenter class's error handling switch statement. The new logic:

  1. First looks for lines explicitly indicating failures (containing "Failed", "exit code", or "hook id:")
  2. If no explicit failure is found, looks for lines that don't indicate success/skip
  3. Only uses the first line if it's not a success-related message
  4. Falls back to a generic error message if only success messages are present

Testing

  • Verify that actual hook failures show meaningful error messages
  • Verify that success messages are not displayed as errors
  • Verify that informational messages are filtered appropriately

Copilot AI review requested due to automatic review settings December 10, 2025 16:29
@vs-code-engineering
Copy link

vs-code-engineering bot commented Dec 10, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/commands.ts

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 improves error message extraction in the Git extension's error handling to prevent displaying misleading success/informational messages when Git hooks fail. The enhancement adds intelligent filtering to prioritize actual failure indicators over generic output.

Key changes:

  • Implemented multi-stage filtering logic to identify actual error messages in Git hook failures
  • Added detection patterns for failure indicators ("Failed", "exit code", "hook id")
  • Added exclusion patterns for success/skip messages to prevent them from being displayed as errors

@fabio-andre-rodrigues
Copy link
Author

@microsoft-github-policy-service agree [company="OutSystems"]

@fabio-andre-rodrigues
Copy link
Author

fabio-andre-rodrigues commented Dec 10, 2025

@microsoft-github-policy-service agree company="OutSystems"

Extracted regex patterns into constants: Created FAILURE_PATTERNS and SUCCESS_PATTERNS arrays at the top of the default case block to eliminate duplication and improve maintainability.
Used the constants throughout: All regex pattern checks now use these constants via .some(pattern => pattern.test(line)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants