summaryrefslogtreecommitdiff
path: root/.githooks
diff options
context:
space:
mode:
Diffstat (limited to '.githooks')
-rwxr-xr-x.githooks/commit-msg15
-rwxr-xr-x.githooks/pre-commit42
-rwxr-xr-x.githooks/pre-push18
3 files changed, 75 insertions, 0 deletions
diff --git a/.githooks/commit-msg b/.githooks/commit-msg
new file mode 100755
index 0000000..33d6a5f
--- /dev/null
+++ b/.githooks/commit-msg
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+# Commit message hook - enforce conventional commit format (optional)
+
+commit_regex='^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\(.+\))?!?: .{1,50}|^fixup!'
+
+if ! grep -qE "$commit_regex" "$1"; then
+ echo "โŒ Invalid commit message format!"
+ echo ""
+ echo "Format: type(scope): description"
+ echo "Types: feat, fix, docs, style, refactor, test, chore, build, ci, perf"
+ echo "Example: feat(auth): add user login functionality"
+ echo ""
+ echo "Your message: $(cat $1)"
+ exit 1
+fi
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000..95ecd68
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+# Pre-commit hook - fast checks only
+# dependencies: php git bash grep xargs composer
+
+set -e
+
+echo "๐Ÿ” Running pre-commit checks..."
+
+# Check if we have staged files
+if git diff --cached --quiet; then
+ echo "No staged changes found."
+ exit 0
+fi
+
+# Lint only staged files
+echo "๐Ÿ“ Linting staged files..."
+
+# Get staged Go files
+STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$' || true)
+
+if [ -n "$STAGED_FILES" ]; then
+ # Run Go linting on staged files
+ go vet ./...
+ if [ $? -eq 0 ]; then
+ echo "โœ… go vet passed"
+ else
+ echo "โŒ go vet failed"
+ exit 1
+ fi
+
+ golangci-lint run ./...
+ if [ $? -eq 0 ]; then
+ echo "โœ… golangci-lint passed"
+ else
+ echo "โŒ golangci-lint failed"
+ exit 1
+ fi
+else
+ echo "โญ๏ธ Nothing to lint, skipping..."
+fi
+
+echo "๐ŸŽ‰ Pre-commit checks completed successfully!"
diff --git a/.githooks/pre-push b/.githooks/pre-push
new file mode 100755
index 0000000..daf4be4
--- /dev/null
+++ b/.githooks/pre-push
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+# Pre-push hook - run tests before pushing
+
+set -e
+
+echo "๐Ÿงช Running tests before push..."
+
+# Run the full test suite
+go test ./...
+
+if [ $? -eq 0 ]; then
+ echo "โœ… All tests passed! Push allowed."
+ exit 0
+else
+ echo "โŒ Tests failed! Push blocked."
+ echo "Fix the failing tests before pushing."
+ exit 1
+fi