Skip to content

Commit 0338776

Browse files
authored
Graceful depth on get-changed-files script (#54913)
1 parent bccc5e1 commit 0338776

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.github/actions/get-changed-files/get-changed-files.sh

+17-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,23 @@ if [ -z "$DIFF" ]; then
3131
echo "__ using branch name $INPUT_HEAD __"
3232
git fetch origin main --depth 1
3333
echo "__ running git diff __"
34-
DIFF=$(git diff --name-only origin/main $INPUT_HEAD)
34+
35+
temp_file=$(mktemp)
36+
git diff --name-only origin/main $INPUT_HEAD > "$temp_file" 2>/dev/null
37+
GIT_EXIT_CODE=$?
38+
39+
DIFF=$(cat "$temp_file")
40+
rm -f "$temp_file"
41+
42+
if [ $GIT_EXIT_CODE -ne 0 ]; then
43+
echo "__ git diff failed with exit code $GIT_EXIT_CODE, fetching unshallow __"
44+
git fetch --depth=100 origin $INPUT_HEAD
45+
git diff --name-only origin/main $INPUT_HEAD > "$temp_file" 2>/dev/null
46+
DIFF=$(cat "$temp_file")
47+
rm -f "$temp_file"
48+
else
49+
echo "__ git diff succeeded __"
50+
fi
3551
fi
3652

3753
# So we can inspect the output

0 commit comments

Comments
 (0)