diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e148df..be0cd86a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- fix(model-stamp): **a model in another git repository no longer blocks every commit** (#805): when CLAUDE.local.md "Project MPR" points at a model in a different repository (a Team Server clone used in place), `git commit` exports `GIT_INDEX_FILE`, `model-stamp.sh` made it absolute (the 2026-09-26 worktree fix), and every `git -C ` then read the project repo's index, found no model files and refused with "refusing to fingerprint an empty set", docs-only commits included. `check --staged` now passes only when the model's real path is outside the work tree being committed to, or the model's own repo top (asked with `GIT_DIR`/`GIT_INDEX_FILE`/`GIT_WORK_TREE` unset) is a separate repo nested strictly under it. Anything else is checked exactly as before: a model inside the committing repo, worktree and `--git-dir` commits, and a `GIT_DIR`/`GIT_WORK_TREE` work tree with no `.git` inside an unrelated outer repo (comparing repo tops alone waved an unverified model through there). Fixture `test-model-stamp.sh` T11: real repos, hook installed; external, nested and outer-repo cases. — thanarat (#805), independent review - new(doctor, bug ledger): **a guard for mxcli's silent MxBuild fallback**: when the project's Mendix version is not in `~/.mxcli/mxbuild/` (and no Studio Pro of that version exists), `mxcli docker build` / `docker check` fall back to the newest cached MxBuild and print its path but no version warning (`run --local` is exact-or-refuse); `bin/doctor.sh` now warns, naming the model version, the cached ones and `./mxcli setup mxbuild -p .mpr` (`mxtk_mxbuild_cache_gap`, warning only, never changes a gate). Ledger entry `BUG-DRAFT-mxbuild-silent-version-fallback`; upstream issue not filed. — a four-app Mendix build (field run), independent review - fix(gate-check): **a fresh clone no longer FAILs Stage 3 as "stale render"**: `blueprint.html` / `process-map.html` freshness used `[ render -ot source ]`, a nanosecond mtime compare, and a checkout stamps files in directory order (`process-map.html` lands before `process-model.json`), so an unedited project read stale on every clone (reproduced: 200-wireframe checkout, 10 of 10 clones). New `bin/lib/render-fresh.sh` keeps `-ot` as the first test (a pass never flips, no git call) and, only where `-ot` would FAIL, asks git once per render (one `log`, one `status`) whether the source was committed after the render's commit; measured 0.19 s for 200 sources all `-ot`-stale on a 300-commit history (a per-source git version cost 12.9 s). Limit: a depth-1 clone cannot see a genuinely stale render. Field run: a four-app Mendix build checked out on a second machine. — a four-app Mendix build (field run), independent review - fix(test-stack-up, e2e-harness-base): **the app port follows the app's configured port, and a multi-app start is no longer pinned to 8080**: with no `APP_PORTS`, `test-stack-up.sh` puts `RUN_LOCAL_APP_PORT`, then `APP_PORT` from the `.docker/.env` beside the `.mpr` (`apps//.docker/.env`; the project-root one as fallback) first, ahead of the old fixed `8080 8081 8084` tail. A fresh `run --local` start for a model under `apps/` with no handshake and no configured port used to fall back to 8080 for every app (`--app-port 8080`); it now exits 4 naming `RUN_LOCAL_APP_PORT`. `e2e-harness-base.md` states that a PAD/Docker runtime listens on 8080 *inside* the container only. Fixtures T28–T32 added. Field run: a four-app Mendix build on 8081–8084 whose fresh start failed with every app pinned to 8080. — a four-app Mendix build (field run), independent review diff --git a/project-bin/model-stamp.sh b/project-bin/model-stamp.sh index ca78d34c..91895632 100755 --- a/project-bin/model-stamp.sh +++ b/project-bin/model-stamp.sh @@ -340,6 +340,27 @@ case "$cmd" in for a in "$@"; do case "$a" in --staged) staged=1 ;; -q|--quiet) quiet=1 ;; --clean) clean=1 ;; --full) full=1 ;; esac; done say() { [ "$quiet" = 1 ] || echo "$@"; } if [ "$staged" = 1 ]; then + # A model this commit cannot stage (#805: CLAUDE.local.md "Project MPR" pointing at a + # Team Server clone). git commit exports GIT_INDEX_FILE, so every `git -C "$MODEL_DIR"` + # below read the committing repo's index, found no model files in it and refused every + # commit, docs-only included. Pass ONLY when the model's real path is outside the work + # tree being committed to, or the model's own repo top (asked with git's repo variables + # unset) is strictly under that work tree, i.e. a separate nested repo. Anything else falls + # through: a GIT_DIR/GIT_WORK_TREE work tree with no .git inside an unrelated outer repo + # makes the model's "own top" the outer repo, and comparing tops alone waved an unverified + # model through there (independent review of #810). Same repo, worktree and --git-dir + # commits (the T9 cases) keep today's behaviour. + _htop="$(git rev-parse --show-toplevel 2>/dev/null || true)" + _h="$( [ -n "$_htop" ] && cd "$_htop" 2>/dev/null && pwd -P || true)" + _m="$(cd "$MODEL_DIR" 2>/dev/null && pwd -P || true)" + if [ -n "$_h" ] && [ -n "$_m" ]; then + _mtop="$(unset GIT_DIR GIT_INDEX_FILE GIT_WORK_TREE; git -C "$MODEL_DIR" rev-parse --show-toplevel 2>/dev/null || true)" + _mt="$( [ -n "$_mtop" ] && cd "$_mtop" 2>/dev/null && pwd -P || true)" + case "$_m/" in + "$_h"/*) case "$_mt" in "$_h"/?*) say " the model is in another repository ($_mtop), nested in this one — nothing staged here to verify"; exit 0 ;; esac ;; + *) say " the model is outside this work tree (${_mtop:-$_m}) — nothing staged here to verify"; exit 0 ;; + esac + fi in_git || exit 0 _git_info; top="$_GI_TOP" _load_model_paths || exit 1 diff --git a/tests/wave2/test-model-stamp.sh b/tests/wave2/test-model-stamp.sh index 14ad910e..7e266ccc 100755 --- a/tests/wave2/test-model-stamp.sh +++ b/tests/wave2/test-model-stamp.sh @@ -119,5 +119,56 @@ out="$(PROJECT_ROOT="$R" ./bin/model-stamp.sh check 2>&1)"; rc=$? mkdir -p app/mprcontents && printf u > app/mprcontents/x.mxunit && git add app PROJECT_ROOT="$R" git commit -qm stray 2>/dev/null && bad "staged mprcontents with no .mpr committed" || ok "staged model with no .mpr refused" +echo "T11 model in ANOTHER git repository (#805): a commit here cannot stage it, so the hook passes" +# git commit exports GIT_INDEX_FILE; model-stamp.sh exported it absolute (the T9 fix) and then +# `git -C ` read the PROJECT repo's index, found no model files there and refused +# every commit, docs-only included. +M="$WORK/model-repo"; X="$WORK/x"; mkdir -p "$M/mprcontents" "$X/bin" +( cd "$M" && git init -q . && git config user.email t@t && git config user.name t + printf mpr > App.mpr; printf u1 > mprcontents/a.mxunit; git add -A >/dev/null; git commit -qm model ) +cd "$X" && git init -q . && git config user.email t@t && git config user.name t +cp "$TK/project-bin/_common.sh" "$TK/project-bin/model-stamp.sh" "$TK/project-bin/install-project-hooks.sh" bin/ +printf '/.claude/\n' > .gitignore +PROJECT_ROOT="$X" ./bin/install-project-hooks.sh >/dev/null +echo docs > NOTES.md && git add NOTES.md bin .gitignore +out="$(MPR_FILE="$M/App.mpr" git commit -qm docs 2>&1)" && ok "docs-only commit accepted (model in another repo)" || bad "docs-only commit refused" "$out" +echo more >> NOTES.md && git add NOTES.md +out="$(GIT_INDEX_FILE=.git/index MPR_FILE="$M/App.mpr" ./bin/model-stamp.sh check --staged 2>&1)"; rc=$? +[ "$rc" -eq 0 ] && echo "$out" | grep -q "outside this work tree (.*model-repo)" && ok "check --staged names the other repository" || bad "check rc=$rc" "$out" +# The model repo's own commits are still checked: there the model IS in the committing repo. +cd "$M" && printf u1x > mprcontents/a.mxunit && git add mprcontents +out="$(MPR_FILE="$M/App.mpr" GIT_INDEX_FILE="$M/.git/index" "$X/bin/model-stamp.sh" check --staged 2>&1)" \ + && bad "unverified model staged in its own repo passed" "$out" || ok "unverified model staged in its own repo still refused" + +# Nested: the model is its own repo INSIDE this work tree (untracked here). This commit cannot +# stage it either, so a docs-only commit passes. +N="$WORK/n"; mkdir -p "$N/bin" "$N/model/mprcontents" +( cd "$N/model" && git init -q . && git config user.email t@t && git config user.name t + printf mpr > App.mpr; printf u1 > mprcontents/a.mxunit; git add -A >/dev/null; git commit -qm model ) +cd "$N" && git init -q . && git config user.email t@t && git config user.name t +cp "$TK/project-bin/_common.sh" "$TK/project-bin/model-stamp.sh" "$TK/project-bin/install-project-hooks.sh" bin/ +printf '/.claude/\n' > .gitignore +PROJECT_ROOT="$N" ./bin/install-project-hooks.sh >/dev/null +echo docs > NOTES.md && git add NOTES.md bin .gitignore +out="$(MPR_FILE="$N/model/App.mpr" git commit -qm docs 2>&1)" && ok "docs-only commit accepted (model is a separate repo nested here)" || bad "nested model repo: docs-only commit refused" "$out" +# GIT_DIR/GIT_WORK_TREE: the work tree has no .git and sits inside an unrelated OUTER repo, so the +# model folder's "own top" (git variables unset) is the outer repo. Comparing tops alone called +# that "another repository" and waved an unverified model through (independent review of #810). +O="$WORK/outer"; W="$O/wt"; G="$WORK/sep.git"; mkdir -p "$W/bin" "$W/app/mprcontents" +( cd "$O" && git init -q . && git config user.email t@t && git config user.name t && echo o > o.txt && git add o.txt && git commit -qm outer ) +export GIT_DIR="$G" GIT_WORK_TREE="$W" +git init -q && git config user.email t@t && git config user.name t +cd "$W" && cp "$TK/project-bin/_common.sh" "$TK/project-bin/model-stamp.sh" "$TK/project-bin/install-project-hooks.sh" bin/ +printf mpr > app/App.mpr; printf u1 > app/mprcontents/a.mxunit; printf '/.claude/\n' > .gitignore +PROJECT_ROOT="$W" ./bin/install-project-hooks.sh >/dev/null +git add -A >/dev/null; MODEL_UNVERIFIED_OK=1 git commit -qm init 2>/dev/null +[ -f "$G/hooks/pre-commit" ] && ok "hook installed in the separate git dir" || bad "no hook in $G/hooks" +printf u1d > app/mprcontents/a.mxunit && git add app +# Refused for the right reason: a hook crash also refuses, so the check reads the UNVERIFIED line. +if out="$(git commit -qm x 2>&1)"; then bad "GIT_DIR/GIT_WORK_TREE commit inside an outer repo waved an unverified model through" "$out" +elif echo "$out" | grep -q "UNVERIFIED"; then ok "GIT_DIR/GIT_WORK_TREE commit inside an outer repo refused the unverified model (UNVERIFIED)" +else bad "GIT_DIR/GIT_WORK_TREE commit refused, but not as UNVERIFIED" "$out"; fi +unset GIT_DIR GIT_WORK_TREE + echo; echo "model-stamp: $PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ]