From f0d4b208b6be013c564672d13a1dcfd89a087afa Mon Sep 17 00:00:00 2001 From: Abdulhaq Emhemmed Date: Tue, 2 Sep 2025 13:11:43 +0200 Subject: [PATCH 1/2] Allow using latest terragrunt build The current checks for supported version fails if terragrunt has been built from source. This is because the command `terragrunt --version` outputs "terragrunt version latest" which fails the comparisons and stops the pre-commit hook from running. --- hooks/terragrunt-hcl-fmt.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hooks/terragrunt-hcl-fmt.sh b/hooks/terragrunt-hcl-fmt.sh index 82b8af9c..bd1b21d1 100755 --- a/hooks/terragrunt-hcl-fmt.sh +++ b/hooks/terragrunt-hcl-fmt.sh @@ -10,14 +10,15 @@ export PATH=$PATH:/usr/local/bin check_terragrunt_version() { local minimum_supported_version="0.77.22" local current_version + + local version_output + version_output=$(terragrunt --version 2>/dev/null) - if ! command -v terragrunt >/dev/null 2>&1; then - echo "Warning: terragrunt command not found. Proceeding anyway..." >&2 - + if [[ "$version_output" == *"latest"* ]]; then return 0 fi - if ! current_version=$(terragrunt --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1); then + if ! current_version=$(echo "$version_output" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1); then echo "Warning: Could not determine terragrunt version. Proceeding anyway..." >&2 return 0 From ad6b476bd61e304ff9dd6730ce8e0521113dd8db Mon Sep 17 00:00:00 2001 From: Abdulhaq Emhemmed Date: Tue, 2 Sep 2025 13:16:47 +0200 Subject: [PATCH 2/2] Restore check for terragrunt command --- hooks/terragrunt-hcl-fmt.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hooks/terragrunt-hcl-fmt.sh b/hooks/terragrunt-hcl-fmt.sh index bd1b21d1..59514031 100755 --- a/hooks/terragrunt-hcl-fmt.sh +++ b/hooks/terragrunt-hcl-fmt.sh @@ -10,8 +10,14 @@ export PATH=$PATH:/usr/local/bin check_terragrunt_version() { local minimum_supported_version="0.77.22" local current_version - local version_output + + if ! command -v terragrunt >/dev/null 2>&1; then + echo "Warning: terragrunt command not found. Proceeding anyway..." >&2 + + return 0 + fi + version_output=$(terragrunt --version 2>/dev/null) if [[ "$version_output" == *"latest"* ]]; then