Skip to content

Commit 1447488

Browse files
committed
chore: add Git hooks for Rust formatting checks and setup script
1 parent 16ea033 commit 1447488

4 files changed

Lines changed: 50 additions & 4 deletions

File tree

crates/opencontext-core/src/events.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,3 @@ mod tests {
130130
}
131131
}
132132
}
133-
134-

crates/opencontext-core/src/search/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,3 @@ pub enum SearchError {
4343

4444
/// Result type alias for search operations
4545
pub type SearchResult<T> = std::result::Result<T, SearchError>;
46-
47-

scripts/pre-commit

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
#
3+
# Git pre-commit hook for OpenContext
4+
# Checks Rust formatting before allowing commits
5+
#
6+
7+
echo "🔍 Checking Rust formatting..."
8+
9+
# Check if cargo is available
10+
if ! command -v cargo &> /dev/null; then
11+
echo "⚠️ cargo not found, skipping Rust format check"
12+
exit 0
13+
fi
14+
15+
# Check Rust formatting
16+
cd crates/opencontext-core
17+
if ! cargo fmt --check 2>/dev/null; then
18+
echo ""
19+
echo "❌ Rust formatting check failed!"
20+
echo ""
21+
echo "Please run the following command to fix:"
22+
echo " cd crates/opencontext-core && cargo fmt"
23+
echo ""
24+
echo "Then stage the changes and commit again."
25+
exit 1
26+
fi
27+
28+
echo "✅ Rust formatting OK"
29+
exit 0
30+

scripts/setup-hooks.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
#
3+
# Setup Git hooks for OpenContext development
4+
#
5+
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
8+
HOOKS_DIR="$PROJECT_ROOT/.git/hooks"
9+
10+
echo "🔧 Setting up Git hooks..."
11+
12+
# Copy pre-commit hook
13+
cp "$SCRIPT_DIR/pre-commit" "$HOOKS_DIR/pre-commit"
14+
chmod +x "$HOOKS_DIR/pre-commit"
15+
16+
echo "✅ Git hooks installed successfully!"
17+
echo ""
18+
echo "The following hooks are now active:"
19+
echo " - pre-commit: Checks Rust formatting before commits"
20+

0 commit comments

Comments
 (0)