Created
November 22, 2021 22:40
-
-
Save TomMD/37eb1ec999fe4af0e43ee8d3b87711f3 to your computer and use it in GitHub Desktop.
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 script conforms to the Lift Script API v1 | |
declare -a patterns | |
patterns=(XXX TODO FIXME) | |
directory=$1 | |
commit=$2 | |
command=$3 | |
git checkout $commit 2>/dev/null 1>/dev/null | |
SEP="" | |
check_for_bad_pattern() { | |
local pattern=$1 | |
lines=$(grep -I -H -i -n "$pattern" * -R 2>/dev/null | \ | |
grep -v 'check-common-comments') | |
while read -r i ; do | |
file=$(echo $i | cut -d ':' -f 1) | |
line=$(echo $i | cut -d ':' -f 2) | |
echo ${SEP} | |
SEP="," | |
echo "{" | |
echo "\"type\" : \"$pattern\"," | |
echo "\"message\" : \"Marker found at line $line\"," | |
echo "\"file\" : \"$file\"," | |
echo "\"line\" : $line" | |
echo "}" | |
done <<< "$lines" | |
} | |
if [[ "$command" = "version" ]] ; then | |
echo "1" | |
exit 0 | |
elif [[ "$command" = "applicable" ]] ; then | |
echo "true" | |
exit 0 | |
elif [[ "$command" = "run" ]] ; then | |
pushd $directory 1>/dev/null 2>&1 | |
echo "[" | |
for i in ${patterns[@]} ; do | |
check_for_bad_pattern "$i" | |
done | |
echo "]" | |
popd 1>/dev/null 2>&1 | |
else | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment