Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Split Swift and Clang format for pre-commit #2380

Merged
merged 5 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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