feat(hooks): Add Git hooks installation system#248
Conversation
🔍 PR Validation ResultsBuild Status: ❌ Failed This comment was automatically generated by the PR validation workflow. |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a Git hooks installation system as the final component of the hybrid workflow implementation, providing automated enforcement of commit standards and seamless integration with the development process.
Key changes:
- Installation script for managing Git hooks templates and deployment
- Pre-commit hook enforcing Claude Code standards with hybrid workflow integration
- Post-commit hook for automatic pushing to maintain single source of truth
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/install-hooks.sh | Installation script that deploys hooks from templates with backup functionality |
| scripts/git-hooks/pre-commit | Pre-commit hook enforcing commit size limits, protected files, and duplicate type checking |
| scripts/git-hooks/post-commit | Post-commit hook for automatic pushing and Git LFS integration |
| DUPLICATES="" | ||
| for file in $STAGED_SWIFT_FILES; do | ||
| # Extract public type names from staged content | ||
| git show ":$file" 2>/dev/null | grep -E "^public (class|struct|enum|protocol|actor) " | \ |
There was a problem hiding this comment.
The duplicate type check may fail when processing new files that don't exist in the current commit. Consider using git diff --cached to get staged content instead of git show ":$file".
| git show ":$file" 2>/dev/null | grep -E "^public (class|struct|enum|protocol|actor) " | \ | |
| git diff --cached -- "$file" 2>/dev/null | grep -E "^public (class|struct|enum|protocol|actor) " | \ |
| echo -e "${GREEN}✅ Successfully pushed $BRANCH to origin${NC}" | ||
|
|
||
| # Update sync timestamp | ||
| SYNC_FILE=".github/sync-status/local-push.json" |
There was a problem hiding this comment.
The sync file is created in the working directory but never committed or pushed. This could lead to untracked files accumulating in the repository. Consider using a different location outside the git repository or adding this to .gitignore.
| sed -E 's/^public (class|struct|enum|protocol|actor) ([A-Za-z0-9_]+).*/\2/' | \ | ||
| while read -r type_name; do | ||
| # Check if this type already exists in other files | ||
| existing=$(git grep -l "^public \(class\|struct\|enum\|protocol\|actor\) $type_name" -- '*.swift' | grep -v "^$file:") |
There was a problem hiding this comment.
The grep pattern uses ^$file: but git grep -l returns only filenames, not filename: format. This grep filter will never match and won't properly exclude the current file from duplicate detection.
| existing=$(git grep -l "^public \(class\|struct\|enum\|protocol\|actor\) $type_name" -- '*.swift' | grep -v "^$file:") | |
| existing=$(git grep -l "^public \(class\|struct\|enum\|protocol\|actor\) $type_name" -- '*.swift' | awk -v current_file="$file" '$0 != current_file') |
|
|
||
| if [ -n "$STAGED_SWIFT_FILES" ]; then | ||
| # Check for new duplicate types in staged files | ||
| DUPLICATES="" |
There was a problem hiding this comment.
The DUPLICATES variable is set within a while loop subshell and won't be accessible outside the loop. This means the duplicate detection check at line 106 will always pass even when duplicates are found.
| DUPLICATES="" | |
| DUPLICATES=() |
Update PR validation workflow to gracefully handle PRs that contain no Swift files (like workflow-only or documentation PRs): - Check for Swift files before running SwiftLint - Skip Xcode build steps for non-Swift PRs - Make Swift-specific checks conditional This fixes CI failures for PRs #244-#248 which only contain workflow files and scripts. Co-authored-by: Claude <claude@anthropic.com>
Update PR validation workflow to gracefully handle PRs that contain no Swift files (like workflow-only or documentation PRs): - Check for Swift files before running SwiftLint - Skip Xcode build steps for non-Swift PRs - Make Swift-specific checks conditional This fixes CI failures for PRs #244-#248 which only contain workflow files and scripts. Co-authored-by: Claude <claude@anthropic.com>
- Check if PR contains Swift file changes before running SwiftLint - Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs - Fixes CI failures on workflow-only PRs like #244-#248 This properly handles PRs that only modify workflows, scripts, or documentation without triggering Swift-related validations.
* fix(ci): Only run Swift checks on PRs with Swift changes - Check if PR contains Swift file changes before running SwiftLint - Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs - Fixes CI failures on workflow-only PRs like #244-#248 This properly handles PRs that only modify workflows, scripts, or documentation without triggering Swift-related validations. * fix(ci): Also check Swift changes for project generation step The check_swift step needs to use the has_swift_changes output to avoid trying to generate Xcode projects for non-Swift PRs.
Add system for managing and installing Git hooks: - Pre-commit hook with updated limits (30 files, 800 lines) - Post-commit auto-push hook for single source of truth - Install script for easy setup - Hooks stored in version control for consistency Changes to pre-commit hook: - Updated documentation to mention hybrid workflow - Added branch awareness (shows hint for feature branches) - Maintained all existing checks (size, protected files, duplicates) This ensures all developers use the same hooks and can easily update them when the workflow evolves. Part 5 of the hybrid workflow implementation. Co-authored-by: Claude <claude@anthropic.com>
af3e74e to
54add12
Compare
🔍 PR Validation ResultsBuild Status: ✅ Passed This comment was automatically generated by the PR validation workflow. |
🪝 Git Hooks Installation System
This PR adds a system for managing Git hooks as part of the hybrid workflow.
What this adds:
scripts/git-hooks/:pre-commit- Enforces commit standards (30 files, 800 lines)post-commit- Auto-pushes for single source of truthscripts/install-hooks.sh):Pre-commit hook updates:
Installation:
Why this matters:
This is Part 5 of 5 of the hybrid workflow implementation.
Summary
With this PR, the hybrid workflow implementation is complete:
Git hooks ensure consistent development practices across the team.