Fix frontend pre-commit hook syntax error and improve reliability #1546#1547
Open
TheBinaryAVA wants to merge 1 commit into
Open
Fix frontend pre-commit hook syntax error and improve reliability #1546#1547TheBinaryAVA wants to merge 1 commit into
TheBinaryAVA wants to merge 1 commit into
Conversation
Signed-off-by: TheBinaryAVA <avanthikapari1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this change?
This change fixes a syntax error in the frontend pre-commit hook script and improves its reliability. The issue was caused by invalid trailing text after exit 0, which could break script execution. The update also ensures the hook only runs when frontend files are staged and behaves more safely.
#closes 1546
How was this change implemented?
Removed invalid trailing text after exit 0
Improved staged file detection using a safer grep -q check
Added set -e to ensure the script fails fast on errors
Refactored structure for better readability and maintainability
Ensured the hook only runs for changes under client/webui/frontend/
Key Design Decisions (optional - delete if not applicable)
Used git diff --cached --name-only with grep -q instead of storing output in a variable for simplicity and reliability
Added set -e to enforce strict error handling rather than manually checking each command
Kept the script POSIX-compliant (/bin/sh) for maximum compatibility
How was this change tested?
Manual testing: staged frontend and non-frontend files and verified hook execution behavior
Unit tests: not applicable (shell hook script)
Integration tests: validated via local git commit flow
Known limitations: does not lint only changed files (runs full npm run precommit if triggered)
Is there anything the reviewers should focus on/be aware of?
Ensure hook triggers only for client/webui/frontend/ changes
Confirm no unintended execution for unrelated file changes
Verify npm script exit codes correctly propagate to git commit flow
Review POSIX compatibility assumptions if environment differs