Skip to content

Commit

Permalink
build: Split Swift and Clang format for pre-commit (#2380)
Browse files Browse the repository at this point in the history
Split formatting swift and clang files for pre-commit.
  • Loading branch information
philipphofmann authored Nov 14, 2022
1 parent cd8dad3 commit 9754750
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
16 changes: 12 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ repos:

- repo: local
hooks:
- id: clang-format
name: Clang Format
- id: format-clang
name: Format ObjC, ObjC++, C, and C++
entry: make
language: system
types_or: ["objective-c", "objective-c++", "c", "c++", "swift" ]
types_or: ["objective-c", "objective-c++", "c", "c++"]
args:
- "format"
- "format-clang"

- id: format-swift
name: Format Swift
entry: make
language: system
types_or: ["swift" ]
args:
- "format-swift"
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ lint:
swiftlint
.PHONY: lint

# Format all h,c,cpp and m files
format:
format: format-clang format-swift

# Format ObjC, ObjC++, C, and C++
format-clang:
@find . -type f \( -name "*.h" -or -name "*.hpp" -or -name "*.c" -or -name "*.cpp" -or -name "*.m" -or -name "*.mm" \) -and \
! \( -path "**.build/*" -or -path "**Build/*" -or -path "**/Carthage/Checkouts/*" -or -path "**/libs/**" \) \
| xargs clang-format -i -style=file

# Format Swift
format-swift:
swiftlint --fix
.PHONY: format

test:
@echo "--> Running all tests"
Expand Down

0 comments on commit 9754750

Please sign in to comment.