Skip to content

Commit

Permalink
GH-40586: [Dev][C++][Python][R] Use pre-commit for clang-format (#40587)
Browse files Browse the repository at this point in the history
### Rationale for this change

We can run `clang-format` easily than `archery lint` by using `pre-commit`:

* We don't need to install `clang-format-14` separately because `pre-commit` prepare it automatically.
* We don't need to run `cmake` to run `clang-format-14`. 

### What changes are included in this PR?

Add `clang-format` related `pre-commit` configurations.

This doesn't change `archery lint` because our `pre-commit` configurations can't replace `archery lint` entirely yet.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: #40586

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Mar 28, 2024
1 parent 2146ab1 commit c9cb3fa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ repos:
hooks:
- id: cython-lint
args: [--no-pycodestyle]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
name: C++ Format
types_or:
- c++
# - json
# - proto
files: >-
^cpp/
exclude: >-
(
?\.grpc\.fb\.(cc|h)$|
?\.pb\.(cc|h)$|
?_generated.*\.(cc|h)$|
?^cpp/src/arrow/vendored/|
?^cpp/src/generated/|
?^cpp/thirdparty/|
)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
Expand All @@ -65,6 +85,30 @@ repos:
name: MATLAB (C++) Format
files: >-
^matlab/src/cpp/
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
name: Python (C++) Format
files: >-
^python/pyarrow/src/
exclude: >-
(
?\.grpc\.fb\.(cc|h)$|
?.pb\.(cc|h)$|
?^cpp/src/generated/|
)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
name: R (C++) Format
files: >-
^r/src/
exclude: >-
(
?^r/src/arrowExports\.cpp$|
)
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
Expand Down
1 change: 0 additions & 1 deletion cpp/src/arrow/util/windows_compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#endif

#include <winsock2.h>
#include <windows.h>

#include "arrow/util/windows_fixup.h"

Expand Down

0 comments on commit c9cb3fa

Please sign in to comment.