char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Evan HuusPrefer npm ci over install for security (#26601)6ea215d17

char/aliceai-t5-moe
1.3 KiB57 linesraw
1#!/usr/bin/env bash
2#
3# Pre-commit hook for llama-ui
4# Runs: format (staged files only) + type-check
5# Stashes unstaged changes temporarily and restores them after.
6
7# Only run when there are staged changes in tools/ui/
8if ! git diff --cached --name-only | grep -q "^tools/ui/"; then
9    exit 0
10fi
11
12REPO_ROOT=$(git rev-parse --show-toplevel)
13cd "$REPO_ROOT/tools/ui"
14
15# Check that node_modules exists
16if [ ! -d "node_modules" ]; then
17    echo "❌ node_modules not found. Run 'npm ci' first."
18    exit 1
19fi
20
21# Stash unstaged changes in tools/ui/ so they don't interfere
22stash_name="pi-ui-precommit"
23git stash push --keep-index -u -m "$stash_name" -- tools/ui/ 2>/dev/null || true
24
25echo "Running pre-commit checks for llama-ui..."
26
27# Format only staged files
28staged_ui=$(git diff --cached --name-only -- tools/ui/)
29if [ -n "$staged_ui" ]; then
30    echo "$staged_ui" | xargs npm run format
31    format_ok=$?
32    # Re-stage formatted files
33    git add tools/ui/
34else
35    format_ok=0
36fi
37
38# Type-check the clean tree
39npm run check
40check_ok=$?
41
42# Restore stashed changes
43if git stash list | grep -q "$stash_name"; then
44    git stash pop 2>/dev/null || true
45fi
46
47if [ $format_ok -ne 0 ]; then
48    echo "❌ Format failed"
49    exit 1
50fi
51if [ $check_ok -ne 0 ]; then
52    echo "❌ Type check failed"
53    exit 1
54fi
55
56echo "✅ Pre-commit checks passed"
57exit 0