mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
CI: add astyle pre-commit hook
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
DEFAULT:
|
||||
# These formatting options will be used by default.
|
||||
options: "--style=otbs --attach-namespaces --attach-classes --indent=spaces=4 --convert-tabs --align-reference=name --keep-one-line-statements --pad-header --pad-oper --unpad-paren --max-continuation-indent=120"
|
||||
|
||||
submodules:
|
||||
# Don't format the code in submodules
|
||||
check: false
|
||||
include:
|
||||
- "/connectedhomeip/connectedhomeip/"
|
||||
|
||||
not_formatted:
|
||||
# Files which are not supposed to be formatted.
|
||||
# Typically, these are:
|
||||
# - Upstream source code we don't want to modify
|
||||
# - Generated files
|
||||
check: false
|
||||
include:
|
||||
- "/components/esp_matter/zap_common/"
|
||||
- "/examples/demo/badge/components/"
|
||||
+10
-2
@@ -1,13 +1,21 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ ! -x "$(command -v astyle_py)" ]; then
|
||||
echo "astyle_py not found, please install astyle_py:"
|
||||
echo " pip install -U astyle_py==VERSION"
|
||||
echo "where VERSION is the same as in .pre-commit-config.yaml."
|
||||
exit 1
|
||||
fi
|
||||
pushd "$(pwd)"
|
||||
|
||||
cd "${ESP_MATTER_PATH}"
|
||||
|
||||
SRC_FILES="$(find components device_hal examples -regextype posix-egrep -regex ".*\.(c|cpp|cxx|h|hpp|hxx)" |\
|
||||
grep -v -iE '/gen/|/build/|/zap-generated/')"
|
||||
grep -v -iE '/gen/|/build/|/zap-generated/|/managed_components/')"
|
||||
for SRC_FILE in ${SRC_FILES}; do
|
||||
echo "formatting ${SRC_FILE}"
|
||||
clang-format -i "${SRC_FILE}"
|
||||
astyle_py --astyle-version=3.4.7 --rules=tools/ci/astyle-rules.yml "${SRC_FILE}"
|
||||
done
|
||||
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user