This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.2.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.2.x by this push: new a60b81d2b Make the autopep8 clang-format targets quieter (#8944) a60b81d2b is described below commit a60b81d2bfb934bef349dab519b57b7c987d156b Author: Brian Neradt <brian.ner...@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. (cherry picked from commit f3173bb1ab48027a87e5182d9e70428a963d0f4e) --- 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 }