Private
Public Access
1
0
Files
linux_patch_manager/scripts/git-hooks/pre-commit
git-echo 124b5b0e3b feat: add bump-version.sh script for version management
Automates version bumps across all version source files:
- Cargo.toml (PRIMARY - workspace.package.version)
- debian/changelog (prepend new entry)
- debian/control (update Version field)
- scripts/build-package.sh (update VERSION variable)
- frontend/package.json (update version field)
- Stale references check after bump

Usage: ./scripts/bump-version.sh <new_version> <old_version>
2026-05-28 10:52:16 -05:00

37 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# =============================================================================
# Linux Patch Manager — Pre-Commit Hook
# =============================================================================
# Auto-formats Rust code and runs frontend checks before each commit.
# Prevents CI format-check and lint failures by catching issues locally.
# Install: ./scripts/git-hooks/install.sh
# =============================================================================
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
# ── Rust auto-format ──────────────────────────────────────────────────────────
if [[ -f "${REPO_ROOT}/Cargo.toml" ]]; then
echo "[pre-commit] Running cargo fmt --all ..."
cargo fmt --all --manifest-path "${REPO_ROOT}/Cargo.toml" 2>/dev/null
# Re-stage any files that cargo fmt reformatted
STAGED_RS=$(git diff --name-only --diff-filter=ACM -- '*.rs')
if [[ -n "${STAGED_RS}" ]]; then
git add ${STAGED_RS}
fi
fi
# ── Frontend checks ──────────────────────────────────────────────────────────
if [[ -f "${REPO_ROOT}/frontend/package.json" ]]; then
echo "[pre-commit] Running ESLint ..."
cd "${REPO_ROOT}/frontend"
npx eslint src/ --ext .ts,.tsx --max-warnings 0 2>/dev/null
echo "[pre-commit] Running TypeScript type check ..."
npx tsc --noEmit 2>/dev/null
fi
echo "[pre-commit] All checks passed ✓"