Make update-gofmt use ls-files

This commit is contained in:
Tim Hockin 2023-01-13 21:59:36 -08:00
parent b3925d4741
commit 822745512d
No known key found for this signature in database

View File

@ -27,20 +27,17 @@ kube::golang::verify_go_version
cd "${KUBE_ROOT}"
find_files() {
find . -not \( \
\( \
-wholename './output' \
-o -wholename './.git' \
-o -wholename './_output' \
-o -wholename './_gopath' \
-o -wholename './release' \
-o -wholename './target' \
-o -wholename '*/third_party/*' \
-o -wholename '*/vendor/*' \
-o -wholename './staging/src/k8s.io/client-go/*vendor/*' \
\) -prune \
\) -name '*.go'
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/*' `# catches vendor/...` \
':!:*/vendor/*' `# catches any subdir/vendor/...` \
':!:third_party/*' `# catches third_party/...` \
':!:*/third_party/*' `# catches third_party/...` \
':(glob)**/*.go' \
"$@"
}
find_files | xargs gofmt -s -w
git_find -z | xargs -0 gofmt -s -w