Skip to content

Commit

Permalink
check-copyright improvements (kokkos#6399)
Browse files Browse the repository at this point in the history
* check-copyright now cleans up "header" and "header_diff" files

* These changes improve the performance of check-copyright by about 20%
(performance not rigorously tested).

scripts/docker/check_format_cpp.sh on an M2 Max Mac took about 34s
before these changes, and 28s afterwards.

* Shaved another 5s off the run time by piping directly into "diff"
instead of creating a temporary "header" file

* Update scripts/check-copyright

Co-authored-by: Cezary Skrzyński <czars1988@gmail.com>

* Update scripts/check-copyright

Co-authored-by: Cezary Skrzyński <czars1988@gmail.com>

* Update scripts/check-copyright

Co-authored-by: Cezary Skrzyński <czars1988@gmail.com>

* Update scripts/check-copyright

Co-authored-by: Cezary Skrzyński <czars1988@gmail.com>

* Update scripts/check-copyright

Co-authored-by: Cezary Skrzyński <czars1988@gmail.com>

* Changed quoted variable names to have curly braces in them (for
consistent style)

---------

Co-authored-by: Cezary Skrzyński <czars1988@gmail.com>
  • Loading branch information
nliber and cz4rs committed Sep 8, 2023
1 parent 03ba69e commit 582dfea
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions scripts/check-copyright
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
files=`git ls-files | grep -e '.*\.\(cc\|cpp\|hpp\)' | grep -v 'tpls/'`
files=$(git ls-files | grep -e '.*\.\(cc\|cpp\|hpp\)' | grep -v 'tpls/')
echo "" &> scripts/diff_files
tmp=`cat LICENSE_FILE_HEADER | wc -l`
tmp=$(wc -l < LICENSE_FILE_HEADER)
NNEW=$(($tmp))
for file in $files; do
head -n +$NNEW $file &> header
diff header LICENSE_FILE_HEADER &> header_diff
count=`cat header_diff | wc -l`
#echo $file " " COUNT " " $count >> diff_headers
if [ "$count" -ne "0" ]; then
echo $file >> scripts/diff_files
for file in $files
do
head -n +$NNEW "${file}" | diff -q - LICENSE_FILE_HEADER > /dev/null
if [[ "${?}" == 1 ]]
then
echo "${file}" >> scripts/diff_files
fi
done
tmpfile=$(mktemp -t kokkos_diff_files.XXXX)
cat scripts/diff_files | sort &> $tmpfile
mv $tmpfile scripts/diff_files
sort < scripts/diff_files &> "${tmpfile}"
mv "${tmpfile}" scripts/diff_files

0 comments on commit 582dfea

Please sign in to comment.