Jaypore CI

> Jaypore CI: Minimal, Offline, Local CI system.
Log | Files | Refs | README | LICENSE

install-hook.sh (923B)


      1 #!/bin/bash
      2 set -euo pipefail
      3 
      4 # Install a git pre-commit hook that runs Jaypore CI before each commit.
      5 #
      6 # Usage:
      7 #   ./install-hook.sh          # install in the current repo
      8 #   ./install-hook.sh /path    # install in a specific repo
      9 
     10 REPO_ROOT="${1:-$(git rev-parse --show-toplevel)}"
     11 HOOK="${REPO_ROOT}/.git/hooks/pre-commit"
     12 
     13 if [ -f "$HOOK" ]; then
     14     echo "A pre-commit hook already exists at $HOOK"
     15     echo "Back it up or remove it, then re-run this script."
     16     exit 1
     17 fi
     18 
     19 mkdir -p "$(dirname "$HOOK")"
     20 
     21 cat > "$HOOK" << 'EOF'
     22 #!/bin/bash
     23 # Pre-commit hook installed by install-hook.sh
     24 # Runs Jaypore CI lint checks before allowing a commit.
     25 
     26 echo "Running Jaypore CI lint checks..."
     27 if ! git jci run; then
     28     echo ""
     29     echo "Commit blocked: lint checks failed."
     30     echo "Fix the issues above, stage your changes, and try again."
     31     exit 1
     32 fi
     33 EOF
     34 
     35 chmod +x "$HOOK"
     36 echo "Installed pre-commit hook at $HOOK"