diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94ed51a2d..d503304f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -218,16 +218,22 @@ jobs: run: | while read -r file; do commit="$(git -C "$file" rev-parse HEAD)" + commit_date=$(git -C "$file" show -s --format='%ci' HEAD) if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then echo "Submodule '$file': '.gitmodules' lacks 'branch' entry" exit 2 fi - if ! error="$(git -C "$file" fetch -q origin "+refs/heads/$branch:refs/remotes/origin/$branch")"; then + # Without the `--depth=1` fetch, may run into 'error processing shallow info: 4' + if ! error="$(git -C "$file" fetch -q --depth=1 origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then + echo "Submodule '$file': Failed to fetch '$branch': $error" + exit 2 + fi + if ! error="$(git -C "$file" fetch -q --shallow-since="$commit_date" origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then echo "Submodule '$file': Failed to fetch '$branch': $error" exit 2 fi if ! git -C "$file" merge-base --is-ancestor "$commit" "refs/remotes/origin/$branch"; then - echo "Submodule '$file': '$commit' is not on '$branch'" + echo "Submodule '$file': '$commit' is not on '$branch' as of '$commit_date' (branch config: '.gitmodules')" exit 2 fi done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true)