Last active
July 8, 2021 12:59
-
-
Save mnojek/df27843872d936bea50a87980549b715 to your computer and use it in GitHub Desktop.
Robot Framework syntax Git pre-commit hook
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 | |
# this hook checks quality of Robot Framework files using Robocop linter tool | |
# it runs only on changed and staged files with .robot or .resource extension | |
# any issue that is found will be notified and will block the commit operation | |
while read file; do | |
# do a check only on the robot files | |
if [[ "$file" =~ (.robot|.resource)$ ]]; then | |
robocop=$(robocop "$file") | |
status=$? | |
if [ $status -ne 0 ]; then | |
echo "Robot Framework syntax check failed for file: $file" | |
exit 1 | |
fi | |
fi | |
# only check files that are staged | |
done < <(git diff --cached --name-only --diff-filter=ACM) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment