fix(hooks): keep git -c overrides when scrubbing apm's git env
Why: the `git rev-parse --local-env-vars` loop in clean-git-env.sh also unset GIT_CONFIG_PARAMETERS / GIT_CONFIG_COUNT, silently dropping `git -c` overrides (extraHeader, credentials, safe.directory) that apm's remote clones may need. Only the repo-locating vars caused #204. Implementation Notes: - clean-git-env.sh now unsets an explicit list only: GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY, GIT_COMMON_DIR, GIT_PREFIX, GIT_IMPLICIT_WORK_TREE; gates.md updated to match. - apm-pack-check-clean.sh points at the real gates.md paragraph. - run-tests.sh's comment now says git exports GIT_DIR to hooks only from a linked worktree, matching LESSONS.md. - test-apm-hooks-git-env.sh isolates from global/system git config. - Reflow the "Two of these shell out to apm" paragraph in gates.md. Refs #204 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
f2c483ca2c
commit
190d9fb322
5 files changed
+16
-18
No files matched your search
@@ -2,8 +2,8 @@
|
||||
# apm-pack-check-clean pre-push hook: `apm pack --check-versions --check-clean
|
||||
# --dry-run`, run with git's repo-locating env scrubbed first. A script rather
|
||||
# than a bare `apm ...` entry only so it can source that scrub -- see
|
||||
# scripts/lib/clean-git-env.sh and issue #204. Full rationale for the gate
|
||||
# itself: docs/spec/gates.md, "apm-pack-check-clean".
|
||||
# scripts/lib/clean-git-env.sh and issue #204, and docs/spec/gates.md,
|
||||
# "apm-audit-ci", the "apm runs with git's repo-locating env scrubbed" paragraph.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/lib/clean-git-env.sh
|
||||
|
||||
@@ -12,15 +12,9 @@
|
||||
# lock-pinned commit. Hooks run from the worktree root, so plain discovery
|
||||
# finds the right repo once these are gone.
|
||||
#
|
||||
# The explicit list runs first so the scrub holds even if `git rev-parse
|
||||
# --local-env-vars` is unavailable; that call then adds anything else git
|
||||
# considers repo-local (GIT_CONFIG_PARAMETERS, GIT_PREFIX, ...), making the
|
||||
# result a superset of the explicit list.
|
||||
# Config-passing vars (GIT_CONFIG_PARAMETERS, GIT_CONFIG_COUNT) are kept on purpose: they carry `git -c` overrides apm's remote clones may need.
|
||||
#
|
||||
# Not meant to be executed directly -- source it before any git call.
|
||||
|
||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
||||
for _clean_git_env_var in $(git rev-parse --local-env-vars 2>/dev/null); do
|
||||
unset "$_clean_git_env_var"
|
||||
done
|
||||
unset _clean_git_env_var
|
||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR \
|
||||
GIT_PREFIX GIT_IMPLICIT_WORK_TREE
|
||||
Reference in new issue
Block a user