Created
February 25, 2024 21:04
-
-
Save aiKrice/eab2120b53ba34f8649f9b15be6a527f to your computer and use it in GitHub Desktop.
AndroidLint: pre-commit
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 | |
| # Get kotlin files that are staged | |
| staged_files=$(git diff --cached --name-only --diff-filter=d | grep ".kt$") | |
| # Check if we have any Kotlin files to format | |
| if [[ "$staged_files" = "" ]]; then | |
| echo "Android lint skipped: No source files to format." | |
| exit 0 | |
| fi | |
| ./gradlew lint | |
| if [ $? -ne 0 ]; then | |
| echo "Android lint failed, commit denied" | |
| exit 1 | |
| fi | |
| # Add changes to git | |
| echo "$staged_files" | xargs git add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment