summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2016-08-22 14:35:41 -0500
committerAdam J. Stewart <ajstewart426@gmail.com>2016-08-30 15:21:15 -0500
commit679f787a65bf4d8b3aa0c7931da7771bb0b8fb1e (patch)
tree5f3cc664cba403cfc2a7f148494d156e5158a6ab /share
parentc6aa32bb3c96d3e9a6db3789fcdda9f2227e8129 (diff)
downloadspack-679f787a65bf4d8b3aa0c7931da7771bb0b8fb1e.tar.gz
spack-679f787a65bf4d8b3aa0c7931da7771bb0b8fb1e.tar.bz2
spack-679f787a65bf4d8b3aa0c7931da7771bb0b8fb1e.tar.xz
spack-679f787a65bf4d8b3aa0c7931da7771bb0b8fb1e.zip
Add generic changed_files script
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/qa/changed_files31
-rwxr-xr-xshare/spack/qa/run-flake8-tests39
2 files changed, 54 insertions, 16 deletions
diff --git a/share/spack/qa/changed_files b/share/spack/qa/changed_files
new file mode 100755
index 0000000000..9c60b3b20b
--- /dev/null
+++ b/share/spack/qa/changed_files
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+#
+# Description:
+# Returns a list of changed files.
+#
+# Usage:
+# changed_files [<directory> ...]
+# changed_files [<file> ...]
+# changed_files ["*.<extension>" ...]
+#
+# Options:
+# Directories, files, or globs to search for changed files.
+#
+
+# Move to root directory of Spack
+# Allows script to be run from anywhere
+SPACK_ROOT="$(dirname "$0")/../../.."
+cd "$SPACK_ROOT"
+
+# Add changed files that have been committed since branching off of develop
+changed=($(git diff --name-only --find-renames develop... -- "$@"))
+# Add changed files that have been staged but not yet committed
+changed+=($(git diff --name-only --find-renames --cached -- "$@"))
+# Add changed files that are unstaged
+changed+=($(git diff --name-only --find-renames -- "$@"))
+# Add new files that are untracked
+changed+=($(git ls-files --exclude-standard --other -- "$@"))
+
+# Return array
+# Ensure that each file in the array is unique
+printf '%s\n' "${changed[@]}" | sort -u
diff --git a/share/spack/qa/run-flake8-tests b/share/spack/qa/run-flake8-tests
index 9556b0d250..6c9f8968e2 100755
--- a/share/spack/qa/run-flake8-tests
+++ b/share/spack/qa/run-flake8-tests
@@ -1,31 +1,38 @@
#!/usr/bin/env bash
#
-# This script runs source code style checks on Spack.
+# Description:
+# Runs source code style checks on Spack.
+# See $SPACK_ROOT/.flake8 for a list of
+# approved exceptions.
#
-# To run it, you'll need to have the Python flake8 installed locally.
+# Usage:
+# run-flake8-tests
+#
+# Notes:
+# Requires flake8. Can be installed by running:
+# `spack install py-flake8`
+# or:
+# `pip install flake8`
+# and adding the bin directory to your PATH.
#
-PYTHONPATH=./lib/spack:$PYTHONPATH
+# Check for dependencies
flake8="$(which flake8)"
if [[ ! $flake8 ]]; then
echo "ERROR: flake8 is required to run this script."
exit 1
fi
-# Move to Spack root; allows script to be run from anywhere
-cd "$(dirname "$0")/../../.."
+QA_DIR="$(dirname "$0")"
+SPACK_ROOT="$QA_DIR/../../.."
-# 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'))
-# Add new files that are untracked
-changed+=($(git ls-files --exclude-standard --other -- '*.py'))
+# Move to root directory of Spack
+# Allows script to be run from anywhere
+SPACK_ROOT="$(dirname "$0")/../../.."
+cd "$SPACK_ROOT"
-# Ensure that each file in the array is unique
-changed=($(printf '%s\n' "${changed[@]}" | sort -u))
+# Gather array of changed files
+changed=($("$QA_DIR/changed_files" "*.py"))
function cleanup {
# Restore original package files after modifying them.
@@ -80,7 +87,7 @@ if [[ "${changed[@]}" ]]; then
exit 1
fi
else
- echo No core framework files modified.
+ echo No Python files were modified.
fi
exit 0