Skip to content

Commit 2b1aec8

Browse files
authored
fix(terraform_docs): Fix issue with processing multiply files without terraform-docs markers. Issue introduced in v1.95.0 (antonbabenko#720)
A bug in the terraform-docs hook was introduced by the code changes in antonbabenko#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.
1 parent 869a106 commit 2b1aec8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hooks/terraform_docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function terraform_docs {
213213
#
214214
if [[ $add_to_existing == false ]]; then
215215
have_marker=$(grep -o "$insertion_marker_begin" "$output_file") || unset have_marker
216-
[[ ! $have_marker ]] && continue
216+
[[ ! $have_marker ]] && popd > /dev/null && continue
217217
fi
218218
# shellcheck disable=SC2086
219219
terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter $args ./ > /dev/null

0 commit comments

Comments
 (0)