fix branch check when bumping to commit outside of shallow range (#5349)

CI Lint check failed when bumping to a commit outside default shallow
range. Deepen the checkout through the bumped commit date to ensure
history is available for the ancestry check.
This commit is contained in:
Etan Kissling 2023-08-24 20:23:05 +02:00 committed by GitHub
parent ffd4e7a024
commit 4d2fd8c2b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)