From a24ea5fe11c5cb51559c2d4afec2773787a6d2bb Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Mon, 16 Sep 2024 16:23:14 -0500 Subject: [PATCH] fix(terraform_docs) Add missing popd to code that was introduced in v1.95.0 A bug in the terraform-docs hook was introduced by the code changes in #717. [A continue statement was added that is not preceded by a `popd` command](https://github.com/antonbabenko/pre-commit-terraform/blob/869a106a4c8c48f34f58318a830436142e31e10a/hooks/terraform_docs.sh#L216). The bug is only triggered when the hook is processing multiple files where one (or more) of the files does not contain the terraform-docs marker statements. The hook fails to process the remaining files because the working directory is not reset to the root of the repository. --- hooks/terraform_docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index d65bc08e5..72979dc55 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -213,7 +213,7 @@ function terraform_docs { # if [[ $add_to_existing == false ]]; then have_marker=$(grep -o "$insertion_marker_begin" "$output_file") || unset have_marker - [[ ! $have_marker ]] && continue + [[ ! $have_marker ]] && popd > /dev/null && continue fi # shellcheck disable=SC2086 terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter $args ./ > /dev/null