Skip to content

Commit

Permalink
EN-602: Clean untracked and ignored transient files
Browse files Browse the repository at this point in the history
  • Loading branch information
arledesma committed Jul 9, 2021
1 parent a397264 commit 2016fbf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion hooks/terraform-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
# See: https://github.com/hashicorp/terraform/pull/24896

function cleanup() {
git --no-pager status --untracked-files=all "provider.tf" "*/provider.tf" --porcelain=v2 | xargs rm -f
if [ -n "$TF_BUILD" ]; then
# we are in a azure devops pipeline - clean everything
git clean -fdX;
fi

# remove untracked or ignored provider.tf that we may have added during this process
git --no-pager status --untracked-files=all --ignored=matching "provider.tf" "*/provider.tf" --porcelain=v2 | \
grep provider.tf | \
cut -f2- -d' ' | \
grep -vE /$ | \
xargs rm -f
}
export -f cleanup;

Expand Down

0 comments on commit 2016fbf

Please sign in to comment.