e8fe5aaf6a
Determines how many commits to check based on the $FAST8_NUM_COMMITS env variable. If set to "smart", it uses git to try to run against all unsubmitted commits. This allows fast8 to be more useful when actively developing a series of patches. Change-Id: I0adfba626ba2ea3479faf0f6ade712f14d3080d3
26 lines
586 B
Bash
Executable File
26 lines
586 B
Bash
Executable File
#!/bin/bash
|
|
|
|
NUM_COMMITS=${FAST8_NUM_COMMITS:-1}
|
|
|
|
if [[ $NUM_COMMITS = "smart" ]]; then
|
|
# Run on all commits not submitted yet
|
|
# (sort of -- only checks vs. "master" since this is easy)
|
|
NUM_COMMITS=$(git cherry master | wc -l)
|
|
fi
|
|
|
|
echo "Checking last $NUM_COMMITS commits."
|
|
|
|
cd $(dirname "$0")/..
|
|
CHANGED=$(git diff --name-only HEAD~${NUM_COMMITS} | tr '\n' ' ')
|
|
|
|
# Skip files that don't exist
|
|
# (have been git rm'd)
|
|
CHECK=""
|
|
for FILE in $CHANGED; do
|
|
if [ -f "$FILE" ]; then
|
|
CHECK="$CHECK $FILE"
|
|
fi
|
|
done
|
|
|
|
diff -u --from-file /dev/null $CHECK | flake8 --diff
|