#!/bin/bash

# Identify all python files added or modified in pull request
CHANGED_FILES=$(git diff --name-only --diff-filter=AM $TRAVIS_BRANCH...HEAD -- "*.py")

# List is empty if this is not a pull request run or if no python files have changed
[ -z "$CHANGED_FILES" ] && echo There are no relevant changes. Skipping test. && exit 0

pip install -q flake8
echo
echo Running flake8 on changed files
flake8 --select=E711,E712,E713,E714,E721,E722,E901,F401,F402,F403,F632,F811,F812,F821,F822,F841,F901,W191,W602,W603,W604,W605,W606 $CHANGED_FILES
