forked from trent_larson/crowd-funder-for-time-pwa
feat(git): implement debug code prevention system with deliberate installation
Implements comprehensive pre-commit hook system to prevent debug code from reaching protected branches while maintaining developer choice. - Hooks stored in scripts/git-hooks/ (not in .git tree) - Deliberate installation required - no forced behavior - Automated installation script for team members - Comprehensive testing - Branch-aware execution (protected vs feature branches) - Configurable patterns and protected branch list Philosophy: Each developer chooses whether to use the hook, ensuring team flexibility while providing powerful debug code prevention tools.
This commit is contained in:
@@ -18,15 +18,17 @@ A pre-commit hook that automatically detects and prevents debug code from reachi
|
||||
./scripts/install-debug-hook.sh
|
||||
```
|
||||
|
||||
This automatically installs, updates, and verifies the hook in your current repository.
|
||||
This automatically installs, updates, and verifies the hook in your current
|
||||
repository. **Note**: Hooks are not automatically installed - you must run this
|
||||
script deliberately to enable debug code checking.
|
||||
|
||||
## 🔧 Manual Installation
|
||||
|
||||
**Copy files manually:**
|
||||
|
||||
```bash
|
||||
cp .git/hooks/pre-commit /path/to/your/repo/.git/hooks/
|
||||
cp .git/hooks/debug-checker.config /path/to/your/repo/.git/hooks/
|
||||
cp scripts/git-hooks/pre-commit /path/to/your/repo/.git/hooks/
|
||||
cp scripts/git-hooks/debug-checker.config /path/to/your/repo/.git/hooks/
|
||||
chmod +x /path/to/your/repo/.git/hooks/pre-commit
|
||||
```
|
||||
|
||||
@@ -36,12 +38,27 @@ chmod +x /path/to/your/repo/.git/hooks/pre-commit
|
||||
- **`debug-checker.config`** - Configuration file
|
||||
- **`README.md`** - Documentation and troubleshooting
|
||||
|
||||
**Note**: Hooks are stored in `scripts/git-hooks/` and must be deliberately
|
||||
installed by each developer. They are not automatically active.
|
||||
|
||||
## 🎯 How It Works
|
||||
|
||||
1. **Branch Detection**: Only runs on protected branches
|
||||
2. **File Filtering**: Automatically skips tests, scripts, and documentation
|
||||
3. **Pattern Matching**: Detects debug code using regex patterns
|
||||
4. **Commit Prevention**: Blocks commits containing debug code
|
||||
1. **Deliberate Installation**: Hooks must be explicitly installed by each
|
||||
developer
|
||||
2. **Branch Detection**: Only runs on protected branches
|
||||
3. **File Filtering**: Automatically skips tests, scripts, and documentation
|
||||
4. **Pattern Matching**: Detects debug code using regex patterns
|
||||
5. **Commit Prevention**: Blocks commits containing debug code
|
||||
|
||||
## 🔒 Installation Philosophy
|
||||
|
||||
**Why deliberate installation?**
|
||||
|
||||
- **Developer choice**: Each developer decides whether to use the hook
|
||||
- **No forced behavior**: Hooks don't interfere with existing workflows
|
||||
- **Local control**: Hooks are installed locally, not globally
|
||||
- **Easy removal**: Can be uninstalled at any time
|
||||
- **Team flexibility**: Some developers may prefer different tools
|
||||
|
||||
## 🌿 Branch Behavior
|
||||
|
||||
@@ -145,8 +162,8 @@ A test script is available at `scripts/test-debug-hook.sh` to verify the hook wo
|
||||
|
||||
## 📚 Additional Resources
|
||||
|
||||
- **Hook documentation**: `.git/hooks/README.md`
|
||||
- **Configuration**: `.git/hooks/debug-checker.config`
|
||||
- **Hook documentation**: `scripts/git-hooks/README.md`
|
||||
- **Configuration**: `scripts/git-hooks/debug-checker.config`
|
||||
- **Test script**: `scripts/test-debug-hook.sh`
|
||||
- **Installation script**: `scripts/install-debug-hook.sh`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user