Last active
January 12, 2021 20:16
-
-
Save stephanecopin/71f354310f5c32d14c47 to your computer and use it in GitHub Desktop.
Run SwiftLint only on untracked/modified (staged or not)/added swift files from git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if which swiftlint >/dev/null; then | |
count=0 | |
for file_path in $(git ls-files -om --exclude-from=.gitignore | grep ".swift$"); do | |
export SCRIPT_INPUT_FILE_$count=$file_path | |
count=$((count + 1)) | |
done | |
for file_path in $(git diff --cached --name-only | grep ".swift$"); do | |
export SCRIPT_INPUT_FILE_$count=$file_path | |
count=$((count + 1)) | |
done | |
export SCRIPT_INPUT_FILE_COUNT=$count | |
if [ $SCRIPT_INPUT_FILE_COUNT -ne 0 ]; then | |
swiftlint lint --use-script-input-files | |
fi | |
else | |
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment