fix(terraform_docs
): Fix issue with processing multiply files without terraform-docs
markers. Issue introduced in v1.95.0
#720
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Put an
x
into the box if that apply:Description of your changes
A bug in the terraform-docs hook was introduced in #717. In that PR, a
continue
statement was added that is not preceded by apopd
command. 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. I ran into this bug on version 1.96.0 of the hooks and pre-commit version 3.8.0.How can we test changes
Here is a script to reproduce the issue. It creates a repository containing multiple modules. The
pre-commit run -a
command will print an error similar to~/.cache/pre-commit/reporqzucglw/hooks/terraform_docs.sh: line 178: pushd: modules/c: No such file or directory
and module C's README won't be updated by terraform-docs.