Skip to content

Commit 8e9cfbe

Browse files
authored
fix: Update lint-changed.sh
1 parent e0ba630 commit 8e9cfbe

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

.github/scripts/lint-changed.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ echo "Configuring target diff for event: $EVENT_NAME"
1212
# Determine the base branch/commit to diff against
1313
if [ "$EVENT_NAME" = "pull_request" ]; then
1414
# Ensure we have the target branch metadata fetched.
15-
# Note: If this fails due to shallow clone issues, the script will exit safely via set -e
1615
git fetch origin "$BASE_REF" --depth=1 --quiet
1716
BASE_SHA="origin/$BASE_REF"
1817
else
@@ -23,8 +22,13 @@ else
2322
fi
2423
fi
2524

26-
# Extract changed Python files into a Bash array
27-
mapfile -t CHANGED_FILES < <(git diff --name-only --diff-filter=d "$BASE_SHA" -- '*.py' 2>/dev/null || true)
25+
DIFF_OUTPUT=$(git diff --name-only --diff-filter=d "$BASE_SHA" -- '*.py' 2>/dev/null || true)
26+
27+
if [ -n "$DIFF_OUTPUT" ]; then
28+
mapfile -t CHANGED_FILES <<< "$DIFF_OUTPUT"
29+
else
30+
CHANGED_FILES=()
31+
fi
2832

2933
# Execute linters if files exist
3034
if [ ${#CHANGED_FILES[@]} -gt 0 ]; then
@@ -45,3 +49,4 @@ if [ ${#CHANGED_FILES[@]} -gt 0 ]; then
4549
fi
4650
else
4751
echo "✅ No Python files changed in this scope. Skipping checks."
52+
fi

0 commit comments

Comments
 (0)