Skip to content

Commit e25dfb4

Browse files
committed
refactor: single Docker invocation for pre-push hook
- Pre-push hook now sources env.sh + docker/exec.sh and delegates itself, so both format and lint run in one container (not two) - install-hooks.sh sources env.sh for consistent logging - Fix "all scripts" wording in README and CLAUDE.md to clarify that install-hooks.sh runs directly on the host
1 parent 596b455 commit e25dfb4

4 files changed

Lines changed: 22 additions & 17 deletions

File tree

.githooks/pre-push

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ set -e
44
###############################################################################
55
# Git pre-push hook
66
#
7-
# Runs formatting and linting checks before pushing. Delegates to the project
8-
# scripts, which auto-delegate to Docker when run outside the container.
7+
# Runs formatting and linting checks before pushing. Delegates to Docker
8+
# as a single container invocation (via the same mechanism as other scripts).
99
###############################################################################
1010

11-
REPO_ROOT="$(git rev-parse --show-toplevel)"
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../scripts" && pwd)"
12+
source "$SCRIPT_DIR/env.sh"
13+
source "$SCRIPT_DIR/docker/exec.sh"
14+
delegate_to_container "$@"
1215

13-
echo "=== Pre-push: checking formatting ==="
14-
"$REPO_ROOT/scripts/format.sh" --check
16+
log_info "Pre-push: checking formatting..."
17+
"$PROJECT_ROOT/scripts/format.sh" --check
1518

16-
BUILD_DIR="$REPO_ROOT/build"
19+
BUILD_DIR="$PROJECT_ROOT/build"
1720
if [ ! -f "$BUILD_DIR/compile_commands.json" ]; then
18-
echo "=== Pre-push: skipping clang-tidy (no compile_commands.json) ==="
19-
echo "Run ./scripts/build.sh first to enable lint checks."
21+
log_warn "Pre-push: skipping clang-tidy (no compile_commands.json)"
22+
log_warn "Run ./scripts/build.sh first to enable lint checks."
2023
else
21-
echo "=== Pre-push: running clang-tidy ==="
22-
"$REPO_ROOT/scripts/lint.sh"
24+
log_info "Pre-push: running clang-tidy..."
25+
"$PROJECT_ROOT/scripts/lint.sh"
2326
fi

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
1515
./scripts/docs.sh # Generate Doxygen documentation
1616
```
1717

18-
Git hooks live in `.githooks/` (version-controlled). Install once after cloning: `./scripts/install-hooks.sh`
18+
Git hooks live in `.githooks/` (version-controlled). Install once after cloning: `./scripts/install-hooks.sh` (runs directly on the host).
1919

20-
All scripts auto-delegate to Docker when run outside the container (`docker run --rm`). The delegation logic lives in `scripts/docker/exec.sh`, sourced by each script via `scripts/env.sh`. Inside the container or CI (`CI=true`), scripts run directly with no overhead. See `docs/ci-container-delegation.md` for details on the CI strategy and a GHCR upgrade path.
20+
Build and quality scripts auto-delegate to Docker when run outside the container (`docker run --rm`). The delegation logic lives in `scripts/docker/exec.sh`, sourced by each script via `scripts/env.sh`. Inside the container or CI (`CI=true`), scripts run directly with no overhead. See `docs/ci-container-delegation.md` for details on the CI strategy and a GHCR upgrade path.
2121

2222
## Architecture
2323

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ git clone <your-fork> my_project && cd my_project
3131
./scripts/test.sh
3232
```
3333

34-
Every script in `scripts/` auto-delegates to Docker when run from the host. You don't need CMake, clang-format, or any other tool installed locally — just Docker. See [docs/ci-container-delegation.md](docs/ci-container-delegation.md) for details.
34+
Build and quality scripts auto-delegate to Docker when run from the host. You don't need CMake, clang-format, or any other tool installed locally — just Docker. See [docs/ci-container-delegation.md](docs/ci-container-delegation.md) for details.
3535

3636
---
3737

@@ -71,7 +71,7 @@ Every script in `scripts/` auto-delegates to Docker when run from the host. You
7171

7272
## Scripts
7373

74-
All scripts auto-delegate to Docker when run on the host. Inside the container or CI (`CI=true`), they run directly.
74+
Build and quality scripts auto-delegate to Docker when run on the host. Inside the container or CI (`CI=true`), they run directly. `install-hooks.sh` runs directly on the host to configure git.
7575

7676
### Build and Development
7777

scripts/install-hooks.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ set -e
88
# are used automatically. Run once after cloning:
99
#
1010
# ./scripts/install-hooks.sh
11+
#
12+
# This script runs directly on the host (no Docker delegation).
1113
###############################################################################
1214

1315
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14-
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
16+
source "$SCRIPT_DIR/env.sh"
1517

16-
git -C "$REPO_ROOT" config core.hooksPath .githooks
17-
echo "[INFO] Git hooks installed (.githooks/). core.hooksPath set."
18+
git -C "$PROJECT_ROOT" config core.hooksPath .githooks
19+
log_info "Git hooks installed (.githooks/). core.hooksPath set."

0 commit comments

Comments
 (0)