pw_presubmit: Exclude third_party/fuchsia/repo from formatting
Do not automatically format sources that will be imported from
Fuchsia. A .clang-format file is included for these sources, but they
may have been formatted by a different version of clang-format.
Change-Id: I587047340425aa8521abfcf97b77845dae3b834a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/103884
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
diff --git a/PW_PLUGINS b/PW_PLUGINS
index a3047ae..2c71655 100644
--- a/PW_PLUGINS
+++ b/PW_PLUGINS
@@ -11,6 +11,7 @@
# return an int to use as the exit code.
# Pigweed's presubmit check script
+format pw_presubmit.format_code _pigweed_upstream_main
heap-viewer pw_allocator.heap_viewer main
package pw_package.pigweed_packages main
presubmit pw_presubmit.pigweed_presubmit main
diff --git a/pw_presubmit/py/pw_presubmit/format_code.py b/pw_presubmit/py/pw_presubmit/format_code.py
index 82ca003..64e67cf 100755
--- a/pw_presubmit/py/pw_presubmit/format_code.py
+++ b/pw_presubmit/py/pw_presubmit/format_code.py
@@ -565,6 +565,19 @@
return format_paths_in_repo(**vars(arguments(git_paths=True).parse_args()))
+def _pigweed_upstream_main() -> int:
+ """Check and fix formatting for source files in upstream Pigweed.
+
+ Excludes third party sources.
+ """
+ args = arguments(git_paths=True).parse_args()
+
+ # Exclude paths with third party code from formatting.
+ args.exclude.append(re.compile('^third_party/fuchsia/repo/'))
+
+ return format_paths_in_repo(**vars(args))
+
+
if __name__ == '__main__':
try:
# If pw_cli is available, use it to initialize logs.