Skip to content
Snippets Groups Projects
Commit 87d0a7c3 authored by Adam J. Stewart's avatar Adam J. Stewart
Browse files

Always clean up tmp files, even if killed

parent 09c9786f
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,18 @@ changed+=($(git diff --name-only --find-renames -- '*.py')) ...@@ -25,6 +25,18 @@ changed+=($(git diff --name-only --find-renames -- '*.py'))
# Ensure that each file in the array is unique # Ensure that each file in the array is unique
changed=($(printf '%s\n' "${changed[@]}" | sort -u)) changed=($(printf '%s\n' "${changed[@]}" | sort -u))
function cleanup {
# Restore original package files after modifying them.
for file in "${changed[@]}"; do
if [[ -e "${file}.sbak~" ]]; then
mv "${file}.sbak~" "${file}"
fi
done
}
# Cleanup temporary files upon exit or when script is killed
trap cleanup EXIT SIGINT SIGTERM
# Add approved style exemptions to the changed packages. # Add approved style exemptions to the changed packages.
for file in "${changed[@]}"; do for file in "${changed[@]}"; do
# Make a backup to restore later # Make a backup to restore later
...@@ -52,7 +64,6 @@ for file in "${changed[@]}"; do ...@@ -52,7 +64,6 @@ for file in "${changed[@]}"; do
perl -i -pe 's/^(.*(https?|file)\:.*)$/\1 # NOQA: ignore=E501/' $file perl -i -pe 's/^(.*(https?|file)\:.*)$/\1 # NOQA: ignore=E501/' $file
done done
return_code=0
if [[ "${changed[@]}" ]]; then if [[ "${changed[@]}" ]]; then
echo ======================================================= echo =======================================================
echo flake8: running flake8 code checks on spack. echo flake8: running flake8 code checks on spack.
...@@ -64,17 +75,10 @@ if [[ "${changed[@]}" ]]; then ...@@ -64,17 +75,10 @@ if [[ "${changed[@]}" ]]; then
echo "Flake8 checks were clean." echo "Flake8 checks were clean."
else else
echo "Flake8 found errors." echo "Flake8 found errors."
return_code=1 exit 1
fi fi
else else
echo No core framework files modified. echo No core framework files modified.
fi fi
# Restore original package files after modifying them. exit 0
for file in "${changed[@]}"; do
if [[ -e "${file}.sbak~" ]]; then
mv "${file}.sbak~" "${file}"
fi
done
exit $return_code
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment