ci: fix init-submodules empty-worktree check (ls -A counts .git)
A submodule with only a .git pointer looks non-empty to ls -A, so the self-heal skipped every un-checked-out nested submodule. Check for real worktree content instead (find excluding .git).
This commit is contained in:
parent
7173d7e88d
commit
babb887d4b
1 changed files with 5 additions and 1 deletions
|
|
@ -25,7 +25,11 @@ fi
|
||||||
git submodule update --init --recursive --jobs 4 >/tmp/ghost_sub_init.log 2>&1 || true
|
git submodule update --init --recursive --jobs 4 >/tmp/ghost_sub_init.log 2>&1 || true
|
||||||
|
|
||||||
while IFS= read -r path; do
|
while IFS= read -r path; do
|
||||||
if [ ! -d "$path" ] || [ -z "$(ls -A "$path" 2>/dev/null)" ]; then
|
# A submodule needs self-healing when it has no .git, or its worktree
|
||||||
|
# has no files other than the .git pointer (ls -A counts .git and would
|
||||||
|
# wrongly treat an un-checked-out submodule as initialized).
|
||||||
|
if [ ! -e "$path/.git" ] ||
|
||||||
|
[ -z "$(find "$path" -mindepth 1 -maxdepth 1 ! -name '.git' -print -quit 2>/dev/null)" ]; then
|
||||||
echo "init-submodules: self-healing empty submodule $path"
|
echo "init-submodules: self-healing empty submodule $path"
|
||||||
if (cd "$path" && git fetch --depth 1 origin >/dev/null 2>&1 &&
|
if (cd "$path" && git fetch --depth 1 origin >/dev/null 2>&1 &&
|
||||||
git checkout -q FETCH_HEAD >/dev/null 2>&1); then
|
git checkout -q FETCH_HEAD >/dev/null 2>&1); then
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue