Skip to content

Commit

Permalink
[infra/cmd] Update format command (#14601)
Browse files Browse the repository at this point in the history
This commit updates format command to skip C/C++ format checking by .clang-format in each directory,
It will not use .FORMATDENY file and manual setting in script any more.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored Feb 4, 2025
1 parent 83ea348 commit 0e58d40
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions infra/command/format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
INVALID_EXIT=0
FILES_TO_CHECK=()
DIRECTORIES_TO_BE_TESTED=()
DIRECTORIES_NOT_TO_BE_TESTED=()
DEFAULT_CLANG_VERSION="16"
CLANG_FORMAT_CANDIDATE=clang-format-$DEFAULT_CLANG_VERSION
PATCH_FILE=format.patch
Expand Down Expand Up @@ -124,16 +123,9 @@ function check_cpp_files() {

# Check c++ files: replace ' ' with newline, check with grep
FILES_TO_CHECK_CPP=`echo "$FILES_TO_CHECK" | tr ' ' '\n' | egrep '((\.c[cl]?)|(\.cpp)|(\.h(pp)?))$'`
# Manually ignore style checking
FILES_TO_CHECK_CPP=`echo "$FILES_TO_CHECK_CPP" | egrep -v '((/NeuralNetworks\.h)|(/NeuralNetworksExtensions\.h))$'`
# Transform to array
FILES_TO_CHECK_CPP=($FILES_TO_CHECK_CPP)

# Skip by '.FORMATDENY' file
for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
FILES_TO_CHECK_CPP=(${FILES_TO_CHECK_CPP[*]/$s*/})
done

if [[ ${#FILES_TO_CHECK_CPP} -ne 0 ]]; then
${CLANG_FORMAT} -i ${FILES_TO_CHECK_CPP[@]}
EXIT_CODE=$?
Expand Down Expand Up @@ -210,10 +202,6 @@ if [[ "${CHECK_DIFF_ONLY}" = "1" ]]; then
fi
fi

for DIR_NOT_TO_BE_TESTED in $(git ls-files -co --exclude-standard '*/.FORMATDENY'); do
DIRECTORIES_NOT_TO_BE_TESTED+=($(dirname "${DIR_NOT_TO_BE_TESTED}"))
done

check_newline
check_permission
check_cpp_files
Expand Down

0 comments on commit 0e58d40

Please sign in to comment.