Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,18 @@ GoZen automatically migrates configurations from previous versions:
## Development

```sh
# Install Git hooks (branch naming validation)
./scripts/install-hooks.sh

# Build
go build -o zen .

# Test
go test ./...
```

**Branch Naming Convention**: All feature branches must follow the format `<type>/<description>` where type is one of: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, `perf`, `ci`, `build`, `revert`. Examples: `feat/user-auth`, `fix/payment-bug`.

Release: Push a tag and GitHub Actions will build automatically.

```sh
Expand Down
24 changes: 24 additions & 0 deletions scripts/install-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Install Git hooks for GoZen development

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
HOOKS_DIR="$REPO_ROOT/.git/hooks"

echo "Installing Git hooks..."

# Install pre-commit hook
cp "$SCRIPT_DIR/pre-commit-hook.sh" "$HOOKS_DIR/pre-commit"
chmod +x "$HOOKS_DIR/pre-commit"

echo "✓ Pre-commit hook installed successfully"
echo ""
echo "Branch naming format: <type>/<description>"
echo "Allowed types: feat, fix, docs, refactor, test, chore, perf, ci, build, revert"
echo ""
echo "Examples:"
echo " - feat/user-authentication"
echo " - fix/payment-processing-bug"
echo " - docs/api-documentation"
41 changes: 41 additions & 0 deletions scripts/pre-commit-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
# Pre-commit hook to validate branch names
# Format: <type>/<description>
# Allowed types: feat, fix, docs, refactor, test, chore, perf, ci, build, revert

# Get current branch name
branch=$(git rev-parse --abbrev-ref HEAD)

# Protected branches (skip validation)
if [ "$branch" = "main" ] || [ "$branch" = "master" ] || [ "$branch" = "develop" ]; then
exit 0
fi

# Skip validation during rebase/merge
if [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ] || [ -f .git/MERGE_HEAD ]; then
exit 0
fi

# Validate branch name format
valid_pattern="^(feat|fix|docs|refactor|test|chore|perf|ci|build|revert)/[a-z0-9-]+$"

if ! echo "$branch" | grep -qE "$valid_pattern"; then
echo ""
echo "❌ Branch name validation failed"
echo ""
echo "Branch: $branch"
echo ""
echo "Error: Branch name does not match the required pattern: <type>/<description>"
echo ""
echo "Valid branch name format: <type>/<description>"
echo "Allowed types: feat, fix, docs, refactor, test, chore, perf, ci, build, revert"
echo ""
echo "Examples:"
echo " - feat/user-authentication"
echo " - fix/payment-processing-bug"
echo " - docs/api-documentation"
echo ""
exit 1
fi

exit 0