Skip to content

Commit d1e9979

Browse files
committed
CU-86b7kybxx - feat: add initial implementation of git hooks for development workflow
0 parents  commit d1e9979

12 files changed

Lines changed: 1063 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Description
10+
A clear and concise description of what the bug is.
11+
12+
## To Reproduce
13+
Steps to reproduce the behavior:
14+
1. Run '...'
15+
2. See error
16+
17+
## Expected behavior
18+
A clear and concise description of what you expected to happen.
19+
20+
## Environment
21+
- OS: [e.g. macOS, Ubuntu]
22+
- Python version: [e.g. 3.11]
23+
- Package version: [e.g. 1.0.0]
24+
25+
## Additional context
26+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Problem
10+
A clear and concise description of what the problem is.
11+
12+
## Proposed Solution
13+
A clear and concise description of what you want to happen.
14+
15+
## Alternatives
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
## Additional context
19+
Add any other context or screenshots about the feature request here.

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Description
2+
Brief description of the changes.
3+
4+
## Type of change
5+
- [ ] Bug fix
6+
- [ ] New feature
7+
- [ ] Breaking change
8+
- [ ] Documentation update
9+
10+
## Checklist
11+
- [ ] My code follows the project style guidelines
12+
- [ ] I have tested my changes locally
13+
- [ ] I have updated the documentation if necessary

.gitignore

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
*.py,cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Environments
56+
.env
57+
.venv
58+
env/
59+
venv/
60+
ENV/
61+
env.bak/
62+
venv.bak/
63+
64+
# IDEs
65+
.idea/
66+
.vscode/
67+
*.swp
68+
*.swo
69+
*~
70+
.project
71+
.pydevproject
72+
.settings/
73+
74+
# macOS
75+
.DS_Store
76+
.AppleDouble
77+
.LSOverride
78+
._*
79+
80+
# Thumbnails
81+
Thumbs.db
82+
ehthumbs.db
83+
84+
# Project specific
85+
*.log

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Dev Tools Hooks
2+
3+
Git hooks for development workflow automation.
4+
5+
## Features
6+
7+
- **commit-msg**: Validates commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format
8+
- **pre-commit**: Runs PHPCS code quality checks for Drupal and WordPress projects
9+
- **pre-push**: Validates branch naming conventions (ClickUp IDs or conventional format)
10+
11+
## Installation
12+
13+
```bash
14+
pip install dev-tools-hooks
15+
```
16+
17+
Or install from source:
18+
19+
```bash
20+
pip install -e .
21+
```
22+
23+
## Usage
24+
25+
### Install hooks in your repository
26+
27+
```bash
28+
# Navigate to your git repository
29+
cd /path/to/your/repo
30+
31+
# Install all hooks
32+
dev-hooks install
33+
34+
# Install specific hooks only
35+
dev-hooks install --hooks commit-msg,pre-push
36+
37+
# Force overwrite existing hooks
38+
dev-hooks install --force
39+
```
40+
41+
### Uninstall hooks
42+
43+
```bash
44+
# Remove all hooks
45+
dev-hooks uninstall
46+
47+
# Remove specific hooks
48+
dev-hooks uninstall --hooks commit-msg
49+
```
50+
51+
### List hooks status
52+
53+
```bash
54+
dev-hooks list
55+
```
56+
57+
## Hook Details
58+
59+
### commit-msg
60+
61+
Validates that commit messages follow Conventional Commits format:
62+
63+
```
64+
<type>(<optional-scope>): <description>
65+
```
66+
67+
Valid types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
68+
69+
Examples:
70+
- `feat: add user authentication`
71+
- `fix(api): resolve timeout issue`
72+
- `docs: update installation guide`
73+
74+
### pre-commit
75+
76+
For PHP projects (Drupal/WordPress), automatically:
77+
- Detects project type from `config.yml`
78+
- Installs PHPCS and coding standards if needed
79+
- Validates staged PHP files against coding standards
80+
81+
### pre-push
82+
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`
87+
88+
## Development
89+
90+
```bash
91+
# Install in development mode
92+
pip install -e .
93+
94+
# Run the CLI
95+
dev-hooks --help
96+
```
97+
98+
## License
99+
100+
MIT

pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "dev-tools-hooks"
7+
version = "1.0.0"
8+
description = "Git hooks for development workflow - Conventional Commits, PHPCS, and branch naming conventions"
9+
readme = "README.md"
10+
license = {text = "MIT"}
11+
requires-python = ">=3.8"
12+
authors = [
13+
{name = "Dev Tools", email = "dev@example.com"}
14+
]
15+
keywords = ["git", "hooks", "conventional-commits", "phpcs", "development"]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Environment :: Console",
19+
"Intended Audience :: Developers",
20+
"License :: OSI Approved :: MIT License",
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Topic :: Software Development :: Version Control :: Git",
29+
]
30+
31+
[project.scripts]
32+
dev-hooks = "dev_tools_hooks.cli:main"
33+
34+
[project.urls]
35+
Homepage = "https://github.com/dev/dev-tools-hooks"
36+
Repository = "https://github.com/dev/dev-tools-hooks"
37+
38+
[tool.setuptools.packages.find]
39+
where = ["src"]
40+
41+
[tool.setuptools.package-data]
42+
dev_tools_hooks = ["hooks/*"]

src/dev_tools_hooks/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Dev Tools Hooks - Git hooks for development workflow.
3+
4+
This package provides git hooks for:
5+
- Conventional Commits validation (commit-msg)
6+
- PHPCS code quality checks for Drupal/WordPress (pre-commit)
7+
- Branch naming conventions (pre-push)
8+
"""
9+
10+
__version__ = "1.0.0"
11+
__author__ = "Dev Tools"
12+
13+
from .installer import install_hooks, uninstall_hooks
14+
15+
__all__ = ["install_hooks", "uninstall_hooks", "__version__"]

0 commit comments

Comments
 (0)