Skip to content

Commit 6053af3

Browse files
Testclaude
andcommitted
chore: convert MAINTAINERS to .md and add git hooks
Changes: - MAINTAINERS.adoc → MAINTAINERS.md (community health file) - Add scripts/install-hooks.sh for git hooks setup - Hooks enforce: SPDX headers, cargo check, cargo fmt, conventional commits Run: ./scripts/install-hooks.sh to enable hooks Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 1e34ecb commit 6053af3

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

File renamed without changes.

scripts/install-hooks.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Install git hooks for WokeLang development
4+
5+
set -e
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
9+
HOOKS_DIR="$REPO_ROOT/.git/hooks"
10+
11+
echo "Installing git hooks..."
12+
13+
# Pre-commit hook
14+
cat > "$HOOKS_DIR/pre-commit" << 'EOF'
15+
#!/usr/bin/env bash
16+
# SPDX-License-Identifier: PMPL-1.0-or-later
17+
# Pre-commit hook for WokeLang
18+
19+
set -e
20+
21+
echo "Running pre-commit checks..."
22+
23+
# Check for SPDX headers in staged files
24+
echo "Checking SPDX headers..."
25+
for file in $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(rs|woke|toml|md|adoc)$'); do
26+
if [ -f "$file" ]; then
27+
if ! head -5 "$file" | grep -q "SPDX-License-Identifier"; then
28+
echo "❌ Missing SPDX header: $file"
29+
echo "Add: // SPDX-License-Identifier: PMPL-1.0-or-later"
30+
exit 1
31+
fi
32+
fi
33+
done
34+
35+
# Run cargo check if Rust files changed
36+
if git diff --cached --name-only | grep -q '\.rs$'; then
37+
echo "Running cargo check..."
38+
cargo check --quiet || {
39+
echo "❌ cargo check failed"
40+
exit 1
41+
}
42+
fi
43+
44+
# Run cargo fmt check if Rust files changed
45+
if git diff --cached --name-only | grep -q '\.rs$'; then
46+
echo "Checking Rust formatting..."
47+
cargo fmt -- --check || {
48+
echo "❌ Rust formatting issues found. Run: cargo fmt"
49+
exit 1
50+
}
51+
fi
52+
53+
# Check .editorconfig compliance
54+
if command -v editorconfig-checker >/dev/null 2>&1; then
55+
echo "Checking EditorConfig compliance..."
56+
editorconfig-checker $(git diff --cached --name-only) || {
57+
echo "⚠️ EditorConfig issues found (non-blocking)"
58+
}
59+
fi
60+
61+
echo "✓ Pre-commit checks passed"
62+
EOF
63+
64+
# Commit-msg hook
65+
cat > "$HOOKS_DIR/commit-msg" << 'EOF'
66+
#!/usr/bin/env bash
67+
# SPDX-License-Identifier: PMPL-1.0-or-later
68+
# Commit message hook for WokeLang
69+
70+
set -e
71+
72+
commit_msg_file=$1
73+
commit_msg=$(cat "$commit_msg_file")
74+
75+
# Check for conventional commit format
76+
if ! echo "$commit_msg" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|chore|build|ci)(\(.+\))?: .+'; then
77+
echo "❌ Commit message must follow conventional commits format:"
78+
echo " type(scope): description"
79+
echo ""
80+
echo " Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci"
81+
echo ""
82+
echo " Example: feat: add consent system runtime enforcement"
83+
exit 1
84+
fi
85+
86+
# Check commit message length
87+
first_line=$(echo "$commit_msg" | head -1)
88+
if [ ${#first_line} -gt 72 ]; then
89+
echo "⚠️ Warning: First line exceeds 72 characters (${#first_line})"
90+
fi
91+
92+
echo "✓ Commit message format valid"
93+
EOF
94+
95+
# Make hooks executable
96+
chmod +x "$HOOKS_DIR/pre-commit"
97+
chmod +x "$HOOKS_DIR/commit-msg"
98+
99+
echo "✓ Git hooks installed successfully"
100+
echo ""
101+
echo "Hooks installed:"
102+
echo " - pre-commit: SPDX headers, cargo check, cargo fmt"
103+
echo " - commit-msg: Conventional commits format"

0 commit comments

Comments
 (0)