Repository navigation
Conversation
|
Instead of adding an option that disables git on The logic behind using In |
git_clean() unconditionally invoked Git, which fails in build
environments that do not provide Git by default and the script
stopped with the following diagnostic (shortened):
configure.php on PHP 8.5.13, libxml 2.9.14
...
sh: 1: git: not found
doc-base/temp clean up FAILED.
The safety of 'git clean -fdx temp' comes from its scoping
(only untracked files under temp/), not from Git itself.
Replace it with a scoped filesystem cleanup using Recursive-
IteratorIterator (CHILD_FIRST, SKIP_DOTS, no symlink following),
preserving the committed temp/.gitkeep marker. On failure, emit
a warning and continue instead of aborting the build, as
suggested in review.
git_status() had the same root cause without the crash: without
Git it produced 6x "sh: git: not found" plus an empty listing,
and with Git installed but Docker ADD-stripped .git directories
(reproducible builds) it produced "fatal: not a git repository"
plus the same empty listing. Fixed with an early `git --version`
check (exec with 2>&1, keeping the shell error off the terminal)
and a per-repo .git check. Cast shell_exec() results to string
to silence trim(null) deprecations on PHP 8.5.
--with-git is removed, following the preference expressed in
review for a soft warning over a new configure option.
|
Reworked as discussed:
Logs are clean now in all three cases: real checkout with Git, Docker |
git_clean() unconditionally invoked Git, which fails in build environments that do not provide Git by default and the script stopped with the following diagnostic (shortened):
The safety of 'git clean -fdx temp' comes from its scoping (only untracked files under temp/), not from Git itself.
Replace it with a scoped filesystem cleanup using RecursiveIteratorIterator (CHILD_FIRST, SKIP_DOTS, no symlink following), preserving the committed temp/.gitkeep marker. On failure, emit a warning and continue instead of aborting the build, as suggested in review.
git_status() had the same root cause without the crash: without Git it produced 6x "sh: git: not found" plus an empty listing, and with Git installed but Docker ADD-stripped .git directories (reproducible builds) it produced "fatal: not a git repository" plus the same empty listing. Fixed with an early
git --versioncheck (exec with 2>&1, keeping the shell error off the terminal) and a per-repo .git check. Cast shell_exec() results to string to silence trim(null) deprecations on PHP 8.5.--with-git is removed, following the preference expressed in review for a soft warning over a new configure option.
To verify the behavior, I ran configure multiple times and compared the before and after of three exemplary file-system entries in the doc-base/temp directory.
After the fix,
temp_clean()behaves identically regardless of Git:..gitkeepdebug.xiold= birth time unchanged from the previous iteration,new= recreated during this iteration.Before the fix, without Git:
sh: git: not found,doc-base/temp clean up FAILEDWith a Git shim (no-op
clean), the build succeeds, but the birth pattern for the three test entries is identical to the after-fix case above — the build recreates everything it needs, so the cleanup made no observable difference in this test.