Skip to content

Commit

Permalink
Add a PREUPLOAD.cfg file to run git-clang-format on every commit
Browse files Browse the repository at this point in the history
The style file .clang-format is copied from adb/.clang-format.
Each sub folders still can have different style by adding their own
.clang-format because git-clang-format uses the style file located
in one of the parent directories of the *source file*.

Also see the following link for previous discussions:

  https://android-review.googlesource.com/#/c/340106

Bug: 36046320
Test: repo upload, checks pre-submit fails when the uploading commit
      doesn't meet the style

Change-Id: I94369af197da1ccce581bbd861c8737f6a197429
  • Loading branch information
bowgotsai committed Mar 8, 2017
1 parent 5811a43 commit 1aeb8d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BasedOnStyle: Google
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false

AccessModifierOffset: -2
ColumnLimit: 100
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
IndentWidth: 4
PointerAlignment: Left
TabWidth: 4
UseTab: Never
PenaltyExcessCharacter: 32
5 changes: 5 additions & 0 deletions PREUPLOAD.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Builtin Hooks]
clang_format = true

[Builtin Hooks Options]
clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp

0 comments on commit 1aeb8d2

Please sign in to comment.