Skip to content

Commit 176f31e

Browse files
committed
CU-86b7kybxx - feat: implement pre-push hook with branch validation and custom command execution
1 parent d1e9979 commit 176f31e

3 files changed

Lines changed: 376 additions & 63 deletions

File tree

.dev-hooks.example.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Dev Tools Hooks Configuration
2+
# Copy this file to .dev-hooks.yml in your project root
3+
4+
# Pre-push commands
5+
# These commands run before pushing to remote
6+
# If any command fails, the push is aborted
7+
pre-push:
8+
# Enable/disable pre-push checks (default: true)
9+
enabled: true
10+
11+
# Skip branch name validation (default: false)
12+
skip_branch_validation: false
13+
14+
# Commands to run before push
15+
# Each command runs in sequence, push is aborted if any fails
16+
commands:
17+
# Example: Run tests
18+
- name: "Run Tests"
19+
run: "pytest"
20+
# Optional: only run for specific branches (regex)
21+
# branches: "^(feat|fix)/.*"
22+
23+
# Example: Run linter
24+
- name: "Lint Check"
25+
run: "ruff check src/"
26+
27+
# Example: Type checking
28+
- name: "Type Check"
29+
run: "mypy src/"
30+
# Optional: allow this command to fail without blocking push
31+
allow_failure: false
32+
33+
# Docker support
34+
# If your project runs in Docker, configure it here
35+
docker:
36+
# Enable docker execution (default: false)
37+
enabled: false
38+
39+
# Container name or service name (for docker-compose)
40+
container: "app"
41+
42+
# Use docker-compose instead of docker exec (default: false)
43+
compose: true
44+
45+
# docker-compose file path (default: docker-compose.yml)
46+
compose_file: "docker-compose.yml"
47+
48+
# Examples for different project types:
49+
50+
# --- Python Project ---
51+
# pre-push:
52+
# commands:
53+
# - name: "Tests"
54+
# run: "pytest -v"
55+
# - name: "Lint"
56+
# run: "ruff check ."
57+
# - name: "Types"
58+
# run: "mypy src/"

README.md

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Git hooks for development workflow automation.
44

55
## Features
66

7-
- **commit-msg**: Validates commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format
7+
- **commit-msg**: Validates commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format (with optional ClickUp ID)
88
- **pre-commit**: Runs PHPCS code quality checks for Drupal and WordPress projects
9-
- **pre-push**: Validates branch naming conventions (ClickUp IDs or conventional format)
9+
- **pre-push**: Validates branch naming + runs custom commands from config file
1010

1111
## Installation
1212

@@ -62,14 +62,16 @@ Validates that commit messages follow Conventional Commits format:
6262

6363
```
6464
<type>(<optional-scope>): <description>
65+
CU-xxxxxxxxx - <type>(<optional-scope>): <description>
6566
```
6667

6768
Valid types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
6869

6970
Examples:
7071
- `feat: add user authentication`
7172
- `fix(api): resolve timeout issue`
72-
- `docs: update installation guide`
73+
- `CU-86b7kybxx - feat: add git hooks`
74+
- `CU-86b7kybxx - fix(auth): resolve login bug`
7375

7476
### pre-commit
7577

@@ -80,14 +82,77 @@ For PHP projects (Drupal/WordPress), automatically:
8082

8183
### pre-push
8284

83-
Validates branch names follow one of these formats:
84-
- ClickUp ID: `CU-xxxxxxxxx` (9 alphanumeric characters)
85-
- Conventional: `<type>/<description>` (e.g., `feat/user-login`, `fix/header-bug`)
86-
- Special branches: `master`, `main`, `develop`, `staging`, `production`
85+
1. **Branch validation** - Validates branch names follow one of these formats:
86+
- ClickUp ID: `CU-xxxxxxxxx`
87+
- Conventional: `<type>/<description>` (e.g., `feat/user-login`, `fix/header-bug`)
88+
- Special branches: `master`, `main`, `develop`, `staging`, `production`
89+
90+
2. **Custom commands** - Runs commands defined in `.dev-hooks.yml` before pushing
91+
92+
## Configuration File
93+
94+
Create a `.dev-hooks.yml` file in your project root to configure custom pre-push commands.
95+
96+
Copy the example file to get started:
97+
98+
```bash
99+
cp .dev-hooks.example.yml .dev-hooks.yml
100+
```
101+
102+
### Example Configuration
103+
104+
```yaml
105+
# Pre-push commands
106+
pre-push:
107+
enabled: true
108+
skip_branch_validation: false
109+
110+
commands:
111+
- name: "Run Tests"
112+
run: "pytest"
113+
114+
- name: "Lint Check"
115+
run: "ruff check src/"
116+
117+
- name: "Type Check"
118+
run: "mypy src/"
119+
120+
# Docker support (optional)
121+
docker:
122+
enabled: false
123+
compose: true
124+
container: "app"
125+
compose_file: "docker-compose.yml"
126+
```
127+
128+
### Docker Support
129+
130+
For dockerized projects, enable docker execution:
131+
132+
```yaml
133+
docker:
134+
enabled: true
135+
compose: true
136+
container: "php"
137+
138+
pre-push:
139+
commands:
140+
- name: "PHPUnit"
141+
run: "vendor/bin/phpunit"
142+
```
143+
144+
Commands will be executed inside the container:
145+
```bash
146+
docker-compose exec -T php vendor/bin/phpunit
147+
```
87148

88149
## Development
89150

90151
```bash
152+
# Create virtual environment
153+
python3 -m venv venv
154+
source venv/bin/activate
155+
91156
# Install in development mode
92157
pip install -e .
93158

0 commit comments

Comments
 (0)