-
Notifications
You must be signed in to change notification settings - Fork 0
fix(preflight): comprehensive pattern validation, CRLF, and network reliability fixes #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1. Fixed LICENSES pattern from ^LICENSES/.\*\.txt$ to ^LICENSES/.*\.txt$ (the escaped asterisk prevented matching any .txt files) 2. Fixed comment filtering pattern from ^(#|[[:space:]]*$) to ^[[:space:]]*(#|$) (now correctly filters indented comments)
Found during comprehensive code review - section was duplicated.
Same fixes as .github repo - see detailed description there. Changes in scripts/preflight.sh: - Added tr -d '\r' to strip Windows CRLF line endings - Added -- to grep -vE to prevent flag injection from dash-prefixed patterns
- grep exit codes: 0=match, 1=no match, 2=error - Previous logic: if pattern matches empty string → valid Problem: '^file\.txt$' is valid but doesn't match '' - New logic: if grep exit != 2 → valid Correctly handles both matching and non-matching patterns - Tested with 6 test cases: all pass ✅
…twork hang - Replace 'git remote show origin' with 'git symbolic-ref' to detect base branch - Avoids SSH/network connection hang when detecting default branch - Faster execution and more reliable in offline/slow network scenarios - Maintains same fallback behavior (defaults to 'main') Resolves the issue where preflight script would hang indefinitely when trying to detect the base branch via network-dependent command.
…issue - actionlint hangs indefinitely when run locally (network timeout) - Keep actionlint enabled in CI where it works reliably - This fixes the pre-push hook hanging issue - Users can uncomment the line to re-enable if needed
- Automatically creates symlink from .git/hooks/pre-push to scripts/preflight.sh - Backs up existing pre-push hook if not a symlink - Makes hook installation consistent across all repos - Complements existing setup-pre-commit.sh script
There was a problem hiding this 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 addresses multiple critical bugs in the preflight script that were causing git pushes to fail or hang indefinitely. The fixes include pattern validation improvements, CRLF compatibility, network reliability enhancements, and documentation cleanup.
Key Changes:
- Fixed pattern validation bugs in
.preflight-excludeparsing (proper comment filtering and CRLF handling) - Eliminated network dependencies causing hangs (replaced
git remote showwithgit symbolic-ref, disabled local actionlint) - Added automated pre-push hook installation script
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/setup-pre-push.sh | New automated script for installing pre-push hook as symlink |
| scripts/preflight.sh | Fixed network hangs, pattern validation, CRLF support, and actionlint timeout |
| CONTRIBUTING.md | Removed duplicate "Bypassing the PR size check" section |
| .preflight-exclude | Fixed regex escape sequence in LICENSES pattern |
…nd validation improvements - Fix CRITICAL bug: capture grep exit code before || true (set +e/set -e pattern) - Remove ineffective chmod +x on symlink in setup-pre-push.sh - Improve pattern validation with more diverse test filenames (README.md, package.json) Addresses Copilot review comment in PR #25
…names - Add more diverse test filenames for overly-broad pattern detection (hidden files, uppercase, numbers, special chars) - Better catch patterns like ^[a-z] that match many but not all files Addresses Copilot review comment
Summary
This PR fixes multiple bugs in the preflight script related to pattern validation, CRLF compatibility, and network reliability. It also disables actionlint locally to prevent network timeout issues.
Fixes
Pattern Validation Bugs (Bugs #7-9)
Bug build(deps-dev): Bump @types/react from 18.3.26 to 19.2.2 #9: Pattern validation logic (
60cbb9c,1c34ff9).preflight-excludeparsingBug build(deps): Bump react-dom from 18.3.1 to 19.2.0 #8: CRLF support (
eb392c1)tr -d '\r'to handle Windows/CRLF line endings--before regexDocumentation cleanup (
d3a8f5c)Network Reliability Fixes
Network hang prevention (
c0bac8c)git remote show originwithgit symbolic-refactionlint hanging issue (
03c8e50)Critical: Exit code bug (
09d4005)|| trueto grep command in regex validationset -euo pipefailcaused script to exit with code 1Tooling
2d9d2a7).githooksdirectoryTesting
All changes have been tested:
Impact
Before: Pre-push hook hung indefinitely or failed with exit 1, blocking all pushes
After: Pre-push hook runs reliably and completes successfully
Related Issues
Checklist