1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Graceful depth on get-changed-files script (#54913)

This commit is contained in:
Hector Alfaro
2025-03-19 14:16:41 -04:00
committed by GitHub
parent bccc5e10b6
commit 03387768c7

View File

@@ -31,7 +31,23 @@ if [ -z "$DIFF" ]; then
echo "__ using branch name $INPUT_HEAD __"
git fetch origin main --depth 1
echo "__ running git diff __"
DIFF=$(git diff --name-only origin/main $INPUT_HEAD)
temp_file=$(mktemp)
git diff --name-only origin/main $INPUT_HEAD > "$temp_file" 2>/dev/null
GIT_EXIT_CODE=$?
DIFF=$(cat "$temp_file")
rm -f "$temp_file"
if [ $GIT_EXIT_CODE -ne 0 ]; then
echo "__ git diff failed with exit code $GIT_EXIT_CODE, fetching unshallow __"
git fetch --depth=100 origin $INPUT_HEAD
git diff --name-only origin/main $INPUT_HEAD > "$temp_file" 2>/dev/null
DIFF=$(cat "$temp_file")
rm -f "$temp_file"
else
echo "__ git diff succeeded __"
fi
fi
# So we can inspect the output