Created
May 19, 2024 15:06
-
-
Save aiKrice/8fecd605309cfe4e88bbf5af53684c21 to your computer and use it in GitHub Desktop.
Xcode build phase running with baseline
This file contains hidden or 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
| #!/bin/sh | |
| #filter unstaged swift files | |
| unstaged_swift_files_relative=$(git status --porcelain | grep -e '^[^\sD]' | grep '\.swift$' | cut -c4- | grep -v '^githooks/') | |
| #filter staged swift files | |
| staged_swift_files_relative=$(git diff --cached --name-only --diff-filter=d | grep '\.swift$' | grep -v '^githooks/') | |
| #Removed duplication with both staged and unstaged files | |
| all_swift_files=$(echo "$staged_swift_files_relative" "$unstaged_swift_files_relative" | sort | uniq) | |
| #Launch only on working files | |
| for file in $all_swift_files | |
| do | |
| /opt/homebrew/bin/swiftlint lint --silence-deprecation-warnings --baseline path/to/baseline.json --config .swiftlint.yml $(realpath "$file") --quiet | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment