#!/bin/bash [ -z "$REVRANGE" ] && REVRANGE="master..HEAD^1" # get a list of changed files, used below; this uses a tempfile to work around # shell behavior when piping to 'while' tempfile=$(mktemp -t tmp.XXXXXX) trap "rm -f ${tempfile}; exit 1" 1 2 3 15 git diff --name-only $REVRANGE | grep '\.py$' > ${tempfile} py_files=() while read line; do if [[ -f "${line}" ]]; then echo "fast-styling ${line}" pipenv run fiximports ${line}; pipenv run autopep8 --in-place --recursive setup.py ${line} pipenv run yapf --style .yapf --recursive -i ${line} fi done < ${tempfile}