Browse Source

Add a repohook to clang-format changes.

It would clang-format according to the local style file in
.clang-format, unless explicitly skipped with --no-verify.

An example output is as follows:

[COMMIT dda6b1ee42] test
[FAILED] clang_format
    The following files have formatting errors:
        screen_ui.cpp
    You can run `/mnt/aosp/aosp-master/tools/repohooks/tools/clang-format.py --fix --clang-format /mnt/aosp/aosp-master/prebuilts/clang/host/linux-x86/clang-stable/bin/clang-format --git-clang-format /mnt/aosp/aosp-master/prebuilts/clang/host/linux-x86/clang-stable/bin/git-clang-format --style file --commit dda6b1ee42` to fix this
[COMMIT be69a2c4ba] Add a repohook to clang-format the change.
[RUNNING 2/2] clang_format
An automatic fix can be attempted for the "clang_format" hook. Do you want to run it? (Yes/no)?
Fix successfully applied. Amend the current commit before attempting to upload again.

More details about repohooks can be found at:

  https://android.googlesource.com/platform/tools/repohooks/

Test: `repo upload` a CL.
Change-Id: Ie8203a317eb3be7acd5592e03374873997647aa0
Tao Bao 3 years ago
parent
commit
6b1aae376a
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      PREUPLOAD.cfg

+ 6
- 0
PREUPLOAD.cfg View File

@@ -0,0 +1,6 @@
1
+[Builtin Hooks]
2
+clang_format = true
3
+
4
+[Builtin Hooks Options]
5
+# Handle native codes only.
6
+clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp