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.5 KiB67 linesraw
1#!/usr/bin/env bash
2#
3# Pre-push hook for llama-ui
4# Runs: lint + test
5# Ignores unstaged changes (stashes them temporarily and restores after).
6
7needs_check=false
8
9# Read refs from stdin: local_ref local_sha remote_ref remote_sha
10while read local_ref local_sha remote_ref remote_sha; do
11    # New branch or force-push — always check
12    if [ "$local_sha" = "0000000000000000000000000000000000000000" ] || \
13       [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
14        needs_check=true
15        continue
16    fi
17
18    # Check for changes in tools/ui/ between remote and local
19    if git diff --name-only "$remote_sha...$local_sha" -- tools/ui/ | grep -q .; then
20        needs_check=true
21    fi
22done
23
24if [ "$needs_check" = false ]; then
25    exit 0
26fi
27
28REPO_ROOT=$(git rev-parse --show-toplevel)
29cd "$REPO_ROOT/tools/ui"
30
31# Check that node_modules exists
32if [ ! -d "node_modules" ]; then
33    echo "❌ node_modules not found. Run 'npm ci' first."
34    exit 1
35fi
36
37# Stash unstaged changes so they don't interfere with checks
38stash_name="pi-ui-prepush"
39git stash push -u -m "$stash_name" -- tools/ui/ 2>/dev/null || true
40
41echo "Running pre-push checks for llama-ui..."
42
43# Lint
44npm run lint
45lint_ok=$?
46
47# Test
48npm test
49test_ok=$?
50
51# Restore stashed changes
52if git stash list | grep -q "$stash_name"; then
53    git stash pop 2>/dev/null || true
54fi
55
56if [ $lint_ok -ne 0 ]; then
57    echo "❌ Lint failed"
58    exit 1
59fi
60
61if [ $test_ok -ne 0 ]; then
62    echo "❌ Tests failed"
63    exit 1
64fi
65
66echo "✅ Pre-push checks passed"
67exit 0