Skip to content

Instantly share code, notes, and snippets.

@ilyapuchka
Last active July 15, 2019 15:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ilyapuchka/f27ec248c2ccac270e9e5003d458000d to your computer and use it in GitHub Desktop.
Save ilyapuchka/f27ec248c2ccac270e9e5003d458000d to your computer and use it in GitHub Desktop.
Run swiftlint only on files changed from the latest commit
!/bin/sh
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
FILES=($(git ls-files -m | grep ".*\.swift$" | grep -v ".*R.generated.swift$"))
if [[ ${FILES[@]} ]]; then
export "SCRIPT_INPUT_FILE_COUNT"="${#FILES[@]}"
for i in "${!FILES[@]}"; do
export "SCRIPT_INPUT_FILE_$i"="${FILES[$i]}"
done
$SRCROOT/../Utils/swiftlint autocorrect --use-script-input-files
$SRCROOT/../Utils/swiftlint lint --use-script-input-files
fi
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment