forked from github/pre-commit-opentofu
feat: Improved speed of pre-commit run -a for multiple hooks (#338)
This commit is contained in:
parent
c266d4036b
commit
579dc45fb4
3 changed files with 54 additions and 0 deletions
|
|
@ -43,4 +43,22 @@ function per_dir_hook_unique_part {
|
||||||
return $exit_code
|
return $exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Unique part of `common::per_dir_hook`. The function is executed one time
|
||||||
|
# in the root git repo
|
||||||
|
# Arguments:
|
||||||
|
# args (string with array) arguments that configure wrapped tool behavior
|
||||||
|
#######################################################################
|
||||||
|
function run_hook_on_whole_repo {
|
||||||
|
local -r args="$1"
|
||||||
|
|
||||||
|
# pass the arguments to hook
|
||||||
|
# shellcheck disable=SC2068 # hook fails when quoting is used ("$arg[@]")
|
||||||
|
tfsec "$(pwd)" ${args[@]}
|
||||||
|
|
||||||
|
# return exit code to common::per_dir_hook
|
||||||
|
local exit_code=$?
|
||||||
|
return $exit_code
|
||||||
|
}
|
||||||
|
|
||||||
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,22 @@ function per_dir_hook_unique_part {
|
||||||
return $exit_code
|
return $exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Unique part of `common::per_dir_hook`. The function is executed one time
|
||||||
|
# in the root git repo
|
||||||
|
# Arguments:
|
||||||
|
# args (string with array) arguments that configure wrapped tool behavior
|
||||||
|
#######################################################################
|
||||||
|
function run_hook_on_whole_repo {
|
||||||
|
local -r args="$1"
|
||||||
|
|
||||||
|
# pass the arguments to hook
|
||||||
|
# shellcheck disable=SC2068 # hook fails when quoting is used ("$arg[@]")
|
||||||
|
terragrunt hclfmt "$(pwd)" ${args[@]}
|
||||||
|
|
||||||
|
# return exit code to common::per_dir_hook
|
||||||
|
local exit_code=$?
|
||||||
|
return $exit_code
|
||||||
|
}
|
||||||
|
|
||||||
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,22 @@ function per_dir_hook_unique_part {
|
||||||
return $exit_code
|
return $exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Unique part of `common::per_dir_hook`. The function is executed one time
|
||||||
|
# in the root git repo
|
||||||
|
# Arguments:
|
||||||
|
# args (string with array) arguments that configure wrapped tool behavior
|
||||||
|
#######################################################################
|
||||||
|
function run_hook_on_whole_repo {
|
||||||
|
local -r args="$1"
|
||||||
|
|
||||||
|
# pass the arguments to hook
|
||||||
|
# shellcheck disable=SC2068 # hook fails when quoting is used ("$arg[@]")
|
||||||
|
terragrunt run-all validate ${args[@]}
|
||||||
|
|
||||||
|
# return exit code to common::per_dir_hook
|
||||||
|
local exit_code=$?
|
||||||
|
return $exit_code
|
||||||
|
}
|
||||||
|
|
||||||
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue