From 6a49eae42276e693fc87dbad9776680b0aefb1ff Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Fri, 13 Jan 2023 21:57:57 -0800 Subject: [PATCH] Make update-netparse-cve use ls-files --- hack/update-netparse-cve.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/hack/update-netparse-cve.sh b/hack/update-netparse-cve.sh index 7485d989f13..f972af10894 100755 --- a/hack/update-netparse-cve.sh +++ b/hack/update-netparse-cve.sh @@ -45,22 +45,18 @@ popd >/dev/null 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' \ + "$@" } # replace net.ParseIP() and netParseIPCDR -find_files | xargs sloppy-netparser - +git_find -z | xargs -0 sloppy-netparser