1- #! /bin/bash
2-
3- # Pre-push hook for Singularity Language Registry
4- # Final checks before pushing to remote
5-
6- set -e
7-
8- echo " 🚀 Running pre-push checks..."
9-
10- # Colors for output
11- RED=' \033[0;31m'
12- GREEN=' \033[0;32m'
13- YELLOW=' \033[1;33m'
14- NC=' \033[0m' # No Color
15-
16- # Get the remote and branch being pushed to
17- remote=" $1 "
18- url=" $2 "
19-
20- # Check which branch we're pushing to
21- while read local_ref local_sha remote_ref remote_sha; do
22- branch=$( echo " $remote_ref " | sed ' s/refs\/heads\///' )
23-
24- echo " 📍 Pushing to branch: $branch "
25-
26- # Prevent direct push to main
27- if [ " $branch " = " main" ]; then
28- echo -e " ${RED} ❌ Direct push to main branch is not allowed!${NC} "
29- echo -e " ${YELLOW} Please create a pull request from development or a feature branch.${NC} "
30- echo " "
31- echo " Steps:"
32- echo " 1. git checkout -b feature/your-feature"
33- echo " 2. git push origin feature/your-feature"
34- echo " 3. Create a PR on GitHub"
35- exit 1
36- fi
37-
38- # Run comprehensive tests before push
39- echo " 🧪 Running comprehensive tests..."
40- if ! cargo test --all-features --release; then
41- echo -e " ${RED} ❌ Tests failed!${NC} "
42- exit 1
43- fi
44-
45- # Check for outdated dependencies
46- echo " 📦 Checking dependencies..."
47- if command -v cargo-outdated & > /dev/null; then
48- cargo outdated || true
49- fi
50-
51- # Security audit
52- echo " 🔐 Running security audit..."
53- if command -v cargo-audit & > /dev/null; then
54- if ! cargo audit; then
55- echo -e " ${YELLOW} ⚠️ Security vulnerabilities found!${NC} "
56- echo " Consider fixing before pushing"
57- read -p " Continue anyway? (y/N) " -n 1 -r
58- echo
59- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
60- exit 1
61- fi
62- fi
63- fi
64-
65- # Documentation check
66- echo " 📚 Checking documentation..."
67- if ! cargo doc --all-features --no-deps; then
68- echo -e " ${RED} ❌ Documentation build failed!${NC} "
69- exit 1
70- fi
71- done
72-
73- echo -e " ${GREEN} ✅ All pre-push checks passed!${NC} "
1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ # Pre-push hook that runs the project's pre-push task. If Nix is available
5+ # we'll run the command inside the devShell so native libraries are provided.
6+ if command -v nix > /dev/null 2>&1 ; then
7+ echo " 🏗️ Running pre-push checks inside Nix devShell (nix develop)..."
8+ nix develop --command just pre-push
9+ else
10+ echo " ⚠️ Nix not found; running pre-push via just (may fail if native deps missing)..."
11+ just pre-push
12+ fi
0 commit comments