Skip to content

Commit 9754750

Browse files
build: Split Swift and Clang format for pre-commit (#2380)
Split formatting swift and clang files for pre-commit.
1 parent cd8dad3 commit 9754750

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ repos:
1616

1717
- repo: local
1818
hooks:
19-
- id: clang-format
20-
name: Clang Format
19+
- id: format-clang
20+
name: Format ObjC, ObjC++, C, and C++
2121
entry: make
2222
language: system
23-
types_or: ["objective-c", "objective-c++", "c", "c++", "swift" ]
23+
types_or: ["objective-c", "objective-c++", "c", "c++"]
2424
args:
25-
- "format"
25+
- "format-clang"
26+
27+
- id: format-swift
28+
name: Format Swift
29+
entry: make
30+
language: system
31+
types_or: ["swift" ]
32+
args:
33+
- "format-swift"

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ lint:
2222
swiftlint
2323
.PHONY: lint
2424

25-
# Format all h,c,cpp and m files
26-
format:
25+
format: format-clang format-swift
26+
27+
# Format ObjC, ObjC++, C, and C++
28+
format-clang:
2729
@find . -type f \( -name "*.h" -or -name "*.hpp" -or -name "*.c" -or -name "*.cpp" -or -name "*.m" -or -name "*.mm" \) -and \
2830
! \( -path "**.build/*" -or -path "**Build/*" -or -path "**/Carthage/Checkouts/*" -or -path "**/libs/**" \) \
2931
| xargs clang-format -i -style=file
3032

33+
# Format Swift
34+
format-swift:
3135
swiftlint --fix
32-
.PHONY: format
3336

3437
test:
3538
@echo "--> Running all tests"

0 commit comments

Comments
 (0)