From 1ca30675219c639ea9cdf713d686dbb862f00d29 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 24 Nov 2018 10:54:54 +0000 Subject: [PATCH] Bug 540373: Use git ls-files instead of find git ls-files has two benefits: - Only finds tracked files This is necessary because we were having a few cleanups being attempted on ignored files. - Is much faster Change-Id: I5a53497f8ef9c839676b7ef7e3be35171140f4b9 --- releng/scripts/check_code_cleanliness.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/releng/scripts/check_code_cleanliness.sh b/releng/scripts/check_code_cleanliness.sh index f33b61119d3..be8b9f04e03 100755 --- a/releng/scripts/check_code_cleanliness.sh +++ b/releng/scripts/check_code_cleanliness.sh @@ -28,16 +28,16 @@ rm -rf check_code_cleanliness_workspace # The .gitattributes is used as a filter to identify files to check. Patters with # this "# check trailing whitespace" on the line before are checked ## -awk '/# remove trailing whitespace/{getline; print $1}' .gitattributes | \ - while read i ; do \ +awk '/# remove trailing whitespace/{getline; print $1}' .gitattributes | + while read i ; do echo "Removing trailing whitespace on $i files" - find . ! -path "./.git/*" -type f -name "$i" -exec sed -i 's/[ \t]*$//' {} +; \ + git ls-files -- "$i" | xargs sed -i 's/[ \t]*$//' done ## # Add all file types to .gitattributes ## -find . ! -path "./.git/*" -type f -printf "%f\n" | sed -E -e 's/.+\./\\\*\\./' | sort -u | while read i ; do +git ls-files | sed -E '-es@^.*/([^/]+)$@\1@' '-es@.+\.@\\\*\\.@' | sort -u | while read i ; do if ! grep "^$i " .gitattributes > /dev/null then echo "MISSING $i in .gitattributes, adding as text, check if that is correct" @@ -48,7 +48,7 @@ done ## # Copy JDT/PDE preferences ## -find . ! -path "./.git/*" -name .project ! -path './core/org.eclipse.cdt.core/.project' | while read i ; do +git ls-files -- \*\*/.project ':!core/org.eclipse.cdt.core/.project' | while read i ; do d=`dirname $i`; if test ! -e $d/feature.xml; then mkdir -p $d/.settings