diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 6dd66eb20fe..52bd315abcf 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -48,11 +48,20 @@ if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: starting generated_files" fi +# Generate a list of directories we don't want to play in. +DIRS_TO_AVOID=() +kube::util::read-array DIRS_TO_AVOID < <( + git ls-files -cmo --exclude-standard -- ':!:vendor/*' ':(glob)*/**/go.work' \ + | while read -r F; do \ + echo ':!:'"$(dirname "${F}")"; \ + done + ) + function git_find() { # Similar to find but faster and easier to understand. We want to include # modified and untracked files because this might be running against code # which is not tracked by git yet. - git ls-files -cmo --exclude-standard ':!:vendor/*' "$@" + git ls-files -cmo --exclude-standard ':!:vendor/*' "${DIRS_TO_AVOID[@]}" "$@" } function git_grep() { @@ -60,7 +69,7 @@ function git_grep() { # running against code which is not tracked by git yet. # We need vendor exclusion added at the end since it has to be part of # the pathspecs which are specified last. - git grep --untracked "$@" ':!:vendor/*' + git grep --untracked "$@" ':!:vendor/*' "${DIRS_TO_AVOID[@]}" } # Generate a list of all files that have a `+k8s:` comment-tag. This will be