ranger/ranger-tempest-plugin/changed_python_files.sh
stewie925 1231c83f42 Fix Ranger issues
Fix up Ranger Dockerfile and README.rst.
Fix Dockerfile for tempest tests.
Also remove unnecessary directories.

Change-Id: I6d64755c6911919f8527e94a57113d886daf22bc
2018-08-20 17:14:14 +00:00

47 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -e
export TERM=xterm-color
# =========================================================================
# This script will find all the changed python files and run
# 1. flake8
# 3. pylint
# for each of the changed file and provide the relevant output
# =========================================================================
TOXINIDIR=$1
CHECKTYPE=$2
POSTARGS=$3
PYLINTRCFILE=${TOXINIDIR}/pylintrc
FLAKERC=${TOXINIDIR}/flake8rc
# Find all the changed python files that needs to be checked / linted for
# ====================================================================
# If dev is passed as {postargs} then it is indicative that the
# check will be performed in a local dev environment
# Else it is indicative of a pipeline for container build process
# ====================================================================
if [[ "${POSTARGS}" = "dev" ]]; then
CHANGEDFILES=($(git status -s | grep -v 'D' | egrep '\.py' | awk -F ' ' '{print $2}' || true))
LENGTHARR=${#CHANGEDFILES[@]}
else
CHANGEDFILES=($(git diff-tree --no-commit-id --name-only --diff-filter AM -r HEAD | egrep '\.py' || true))
LENGTHARR=${#CHANGEDFILES[@]}
fi
for ((i=0;i<$LENGTHARR; i++));do
echo "$(tput setaf 4)============================================================$(tput setaf 9)"
echo "$(tput setaf 5) Performing check on ${CHANGEDFILES[i]}$(tput setaf 9)"
echo "$(tput setaf 4)============================================================$(tput setaf 9)"
echo ${CHANGEDFILES[i]}
if [[ "${CHECKTYPE}" = "flake" ]]; then
flake8 --config=$FLAKERC ${CHANGEDFILES[i]}
elif [[ "${CHECKTYPE}" = "pylint" ]]; then
pylint -rn --rcfile=$PYLINTRCFILE ${CHANGEDFILES[i]}
fi
done