Created
August 21, 2018 18:54
-
-
Save alexmx/e7647976fdb616c54c42042b83d86a0b to your computer and use it in GitHub Desktop.
Run SwiftLint against files which have been changed in the current branch relative to RELATIVE_BRANCH (eg. master)
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
#!/bin/bash | |
# Path to the repository root folder | |
REPO_ROOT_DIR=$1 | |
# The branch name relative to which the modified files will be determined | |
RELATIVE_BRANCH=$2 | |
# The path to the SwiftLint command. | |
SWIFT_LINT_PATH=$3 | |
run_swiftlint() { | |
local filename="${1}" | |
if [[ "${filename##*.}" == "swift" ]]; then | |
$SWIFT_LINT_PATH lint --path "${filename}" --lenient | |
fi | |
} | |
run_swiftlint_modified_files() { | |
# Run SwiftLint against files which have been changed in the current branch relative to RELATIVE_BRANCH | |
git diff $RELATIVE_BRANCH --name-only | while read filename; do run_swiftlint "${filename}"; done | |
} | |
pushd $REPO_ROOT_DIR | |
run_swiftlint_modified_files | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment