summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2016-08-09 11:09:17 -0500
committerAdam J. Stewart <ajstewart426@gmail.com>2016-08-11 09:53:04 -0500
commit1edfc82123d2185908feb601be3ac7adf5a6da1d (patch)
tree02cf3b45b92bcdf5c68c26d370a4c21b3495c399 /share
parente6a122417aee3dbb0f83c92d23a408a855b07c40 (diff)
downloadspack-1edfc82123d2185908feb601be3ac7adf5a6da1d.tar.gz
spack-1edfc82123d2185908feb601be3ac7adf5a6da1d.tar.bz2
spack-1edfc82123d2185908feb601be3ac7adf5a6da1d.tar.xz
spack-1edfc82123d2185908feb601be3ac7adf5a6da1d.zip
Run flake8 checks on changed uncommitted files
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/qa/run-flake821
1 files changed, 14 insertions, 7 deletions
diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8
index c59bfc9490..2c01800ee9 100755
--- a/share/spack/qa/run-flake8
+++ b/share/spack/qa/run-flake8
@@ -17,11 +17,18 @@ if [[ ! $flake8 ]]; then
exit 1
fi
-# Check if changed files are flake8 conformant [framework]
-changed=$(git diff --name-only --find-renames develop... | grep '.py$')
+# Add changed files that have been committed since branching off of develop
+changed=($(git diff --name-only --find-renames develop... -- '*.py'))
+# Add changed files that have been staged but not yet committed
+changed+=($(git diff --name-only --find-renames --cached -- '*.py'))
+# Add changed files that are unstaged
+changed+=($(git diff --name-only --find-renames -- '*.py'))
+
+# Ensure that each file in the array is unique
+changed=($(printf '%s\n' "${changed[@]}" | sort -u))
# Add approved style exemptions to the changed packages.
-for file in $changed; do
+for file in "${changed[@]}"; do
# Make a backup to restore later
cp "$file" "$file.sbak~"
@@ -48,14 +55,14 @@ for file in $changed; do
done
return_code=0
-if [[ $changed ]]; then
+if [[ "${changed[@]}" ]]; then
echo =======================================================
echo flake8: running flake8 code checks on spack.
echo
echo Modified files:
- echo $changed | perl -pe 's/^/ /;s/ +/\n /g'
+ echo "${changed[@]}" | perl -pe 's/^/ /;s/ +/\n /g'
echo =======================================================
- if flake8 --format pylint $changed; then
+ if flake8 --format pylint "${changed[@]}"; then
echo "Flake8 checks were clean."
else
echo "Flake8 found errors."
@@ -66,7 +73,7 @@ else
fi
# Restore original package files after modifying them.
-for file in $changed; do
+for file in "${changed[@]}"; do
if [[ -e "${file}.sbak~" ]]; then
mv "${file}.sbak~" "${file}"
fi