You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bn...@apache.org on 2022/07/08 16:21:50 UTC
[trafficserver] branch master updated: Make the autopep8 clang-format targets quieter (#8944)
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new f3173bb1a Make the autopep8 clang-format targets quieter (#8944)
f3173bb1a is described below
commit f3173bb1ab48027a87e5182d9e70428a963d0f4e
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Fri Jul 8 11:21:44 2022 -0500
Make the autopep8 clang-format targets quieter (#8944)
This makes our clang-format and autopep8 execution quieter. They will
now only print any files that they modified.
---
tools/autopep8.sh | 19 ++++++++++++++++---
tools/clang-format.sh | 16 ++++++++++++++--
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/tools/autopep8.sh b/tools/autopep8.sh
index 44e6f1ac1..e489627a9 100755
--- a/tools/autopep8.sh
+++ b/tools/autopep8.sh
@@ -71,8 +71,18 @@ function main() {
# Keep this list of Python extensions the same with the list of
# extensions searched for in the tools/git/pre-commit hook.
grep -E '\.py$|\.cli.ext$|\.test.ext$' ${files} > ${files_filtered}
+ # Prepend the filenames with "./" to make the modified file output consistent
+ # with the clang-format target output.
+ sed -i'.bak' 's:^:\./:' ${files_filtered}
+ rm -f ${files_filtered}.bak
- echo "Running autopep8. This may take a minute."
+ # Efficiently retrieving modification timestamps in a platform
+ # independent way is challenging. We use find's -newer argument, which
+ # seems to be broadly supported. The following file is created and has a
+ # timestamp just before running clang-format. Any file with a timestamp
+ # after this we assume was modified by clang-format.
+ start_time_file=${tmp_dir}/format_start.$$
+ touch ${start_time_file}
autopep8 \
--ignore-local-config \
-i \
@@ -82,8 +92,11 @@ function main() {
--aggressive \
--aggressive \
$(cat ${files_filtered})
+ find $(cat ${files_filtered}) -newer ${start_time_file}
+
# The above will not catch the Python files in the metalink tests because
# they do not have extensions.
+ metalink_dir=${DIR}/plugins/experimental/metalink/test
autopep8 \
--ignore-local-config \
-i \
@@ -93,8 +106,8 @@ function main() {
--aggressive \
--aggressive \
--recursive \
- ${DIR}/plugins/experimental/metalink/test
- echo "autopep8 completed."
+ ${metalink_dir}
+ find ${metalink_dir} -newer ${start_time_file}
rm -rf ${tmp_dir}
deactivate
}
diff --git a/tools/clang-format.sh b/tools/clang-format.sh
index c85a5965c..eb142b6b9 100755
--- a/tools/clang-format.sh
+++ b/tools/clang-format.sh
@@ -87,7 +87,17 @@ EOF
exit 1
else
[ ${just_install} -eq 1 ] && return
- for file in $(find $DIR -iname \*.[ch] -o -iname \*.cc -o -iname \*.h.in); do
+
+ # Efficiently retrieving modification timestamps in a platform
+ # independent way is challenging. We use find's -newer argument, which
+ # seems to be broadly supported. The following file is created and has a
+ # timestamp just before running clang-format. Any file with a timestamp
+ # after this we assume was modified by clang-format.
+ start_time_file=$(mktemp -t clang-format-start-time.XXXXXXXXXX)
+ touch ${start_time_file}
+
+ target_files=$(find $DIR -iname \*.[ch] -o -iname \*.cc -o -iname \*.h.in)
+ for file in ${target_files}; do
# The ink_autoconf.h and ink_autoconf.h.in files are generated files,
# so they do not need to be re-formatted by clang-format. Doing so
# results in make rebuilding all our files, so we skip formatting them
@@ -95,9 +105,11 @@ EOF
base_name=$(basename ${file})
[ ${base_name} = 'ink_autoconf.h.in' -o ${base_name} = 'ink_autoconf.h' ] && continue
- echo $file
${FORMAT} -i $file
done
+
+ find ${target_files} -newer ${start_time_file}
+ rm ${start_time_file}
fi
}