Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
exit if there are no relevant changed files, otherwise rubocop will r…
Browse files Browse the repository at this point in the history
…un on all (#7)
  • Loading branch information
toy authored May 13, 2024
1 parent 2aa0a6f commit 4641772
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,28 @@ fi

if [ "${INPUT_ONLY_CHANGED}" = "true" ]; then
echo '::group:: Getting changed files list'

# get intersection of changed files (excluding deleted) with target files for
# rubocop as an array
# shellcheck disable=SC2086
readarray -t CHANGED_FILES < <(
comm -12 \
<(git diff --diff-filter=d --name-only "${BASE_REF}..${HEAD_REF}" | sort) \
<(${BUNDLE_EXEC}rubocop --list-target-files | sort)
)

if (( ${#CHANGED_FILES[@]} == 0 )); then
echo "No relevant files for rubocop, skipping"
exit 0
fi

echo "${CHANGED_FILES[@]}"

if (( ${#CHANGED_FILES[@]} > 100 )); then
echo "More than 100 changed files (${#CHANGED_FILES[@]}), running rubocop on all files"
unset CHANGED_FILES
fi

echo '::endgroup::'
fi

Expand Down

0 comments on commit 4641772

Please sign in to comment.