Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

chore: setup professional pre-commit hooks for fmt and clippy

Samir Hossainsfb8effc86f00
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000..1dbe64b
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Allow bypassing the hook via SKIP_HOOKS=1
+if [ "$SKIP_HOOKS" = "1" ]; then
+ echo "⏭️ SKIP_HOOKS is set. Bypassing pre-commit checks..."
+ exit 0
+fi
+
+# Text color variables
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[0;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+echo "${BLUE}⏳ Running MovieBox-Tui pre-commit checks...${NC}\n"
+
+# 1. Run cargo fmt
+echo "${YELLOW}🦀 1/2 Checking Code Formatting (cargo fmt)...${NC}"
+if ! cargo fmt -- --check; then
+ echo "\n${RED}❌ Error: Code formatting failed!${NC}"
+ echo "${RED}Please run 'cargo fmt' to automatically fix the formatting before committing.${NC}"
+ exit 1
+fi
+echo "${GREEN}✅ Code formatting is perfect.${NC}\n"
+
+# 2. Run cargo clippy
+echo "${YELLOW}🦀 2/2 Checking Linter Warnings (cargo clippy)...${NC}"
+if ! cargo clippy --all-targets --all-features -- -D warnings; then
+ echo "\n${RED}❌ Error: Clippy found warnings or errors in your code!${NC}"
+ echo "${RED}Please fix the warnings above before committing.${NC}"
+ exit 1
+fi
+echo "${GREEN}✅ No clippy warnings found.${NC}\n"
+
+echo "${GREEN}🎉 All checks passed! Committing...${NC}"
+exit 0