Skip to content

Commit

Permalink
chore(release): version 1.77.3 [skip ci]
Browse files Browse the repository at this point in the history
## [1.77.3](antonbabenko/pre-commit-terraform@v1.77.2...v1.77.3) (2023-04-21)

### Bug Fixes

* Updates all dependencies used in Dockerfile and fix Docker image ([antonbabenko#507](antonbabenko#507)) ([dc177fe](antonbabenko@dc177fe))
  • Loading branch information
semantic-release-bot authored and lexton committed Apr 28, 2023
1 parent dc177fe commit 5da4803
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.77.3](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.2...v1.77.3) (2023-04-21)


### Bug Fixes

* Updates all dependencies used in Dockerfile and fix Docker image ([#507](https://github.com/antonbabenko/pre-commit-terraform/issues/507)) ([dc177fe](https://github.com/antonbabenko/pre-commit-terraform/commit/dc177fe29ed250fbb98702248c7de232bdb75f58))

## [1.77.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.1...v1.77.2) (2023-04-09)


Expand Down
19 changes: 17 additions & 2 deletions hooks/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ function common::per_dir_hook {
# run hook for each path
for dir_path in $(echo "${dir_paths[*]}" | tr ' ' '\n' | sort -u); do
dir_path="${dir_path//__REPLACED__SPACE__/ }"
pushd "$dir_path" > /dev/null || continue

if common::check_config_hook_flag_set "--skip-chdir"; then
pushd "$dir_path" > /dev/null || continue
fi

per_dir_hook_unique_part "$dir_path" "${args[@]}"

Expand All @@ -235,7 +238,10 @@ function common::per_dir_hook {
final_exit_code=$exit_code
fi

popd > /dev/null
if common::check_config_hook_flag_set "--skip-chdir"; then
popd > /dev/null
fi

done

# restore errexit if it was set before the "for" loop
Expand Down Expand Up @@ -334,3 +340,12 @@ function common::export_provided_env_vars {
export $var_name="$var_value"
done
}

#######################################################################
# Check if the conifg hook is set in the hook config
# Arguments:
# flag (string) name of the flag to check in the hook config
#######################################################################
function common::check_config_hook_flag_set {
[[ "${HOOK_CONFIG[*]}" =~ (^|[[:space:]])"${1};"($|[[:space:]]) ]]
}
15 changes: 13 additions & 2 deletions hooks/terraform_tflint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ function main {
common::parse_cmdline "$@"
common::export_provided_env_vars "${ENV_VARS[@]}"
common::parse_and_export_env_vars

# TODO: Switch the default behaviour in 2.0
# if ! common::check_config_hook_flag_set "--skip-chdir"; then
# HOOK_CONFIG+=("--skip-chdir;")
# fi

# Support for setting PATH to repo root.
for i in "${!ARGS[@]}"; do
ARGS[i]=${ARGS[i]/__GIT_WORKING_DIR__/$(pwd)\/}
Expand Down Expand Up @@ -50,12 +56,17 @@ function per_dir_hook_unique_part {
shift
local -a -r args=("$@")

DIR_ARGS=""
if common::check_config_hook_flag_set "--skip-chdir"; then
DIR_ARGS="--chdir=$dir_path"
fi

# Print checked PATH **only** if TFLint have any messages
# shellcheck disable=SC2091,SC2068 # Suppress error output
$(tflint ${args[@]} 2>&1) 2> /dev/null || {
$(tflint "$DIR_ARGS" ${args[@]} 2>&1) 2> /dev/null || {
common::colorify "yellow" "TFLint in $dir_path/:"

tflint "${args[@]}"
tflint "$DIR_ARGS" "${args[@]}"
}

# return exit code to common::per_dir_hook
Expand Down

0 comments on commit 5da4803

Please sign in to comment.