File tree Expand file tree Collapse file tree 3 files changed +60
-3
lines changed
Expand file tree Collapse file tree 3 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,15 @@ jobs:
1717 - name : Checkout
1818 uses : actions/checkout@v4
1919
20+ - name : Install Swift
21+ uses : swift-actions/setup-swift@v1
22+ with :
23+ swift-version : ' 5.9'
24+
2025 - name : Install SwiftFormat
2126 run : |
22- wget -O swiftformat.zip https://github.com/nicklockwood/SwiftFormat/archive/0.55.6.zip
23- unzip swiftformat.zip
24- cd SwiftFormat-0.55.6
27+ git clone https://github.com/nicklockwood/SwiftFormat
28+ cd SwiftFormat
2529 swift build -c release
2630 sudo cp .build/release/swiftformat /usr/local/bin/
2731
Original file line number Diff line number Diff line change @@ -57,6 +57,35 @@ The Split team monitors all issues submitted to this [issue tracker](https://git
5757## Contributing
5858Please see [ Contributors Guide] ( CONTRIBUTORS-GUIDE.md ) to find all you need to submit a Pull Request (PR).
5959
60+ ## Development
61+
62+ ### Code Formatting
63+
64+ This project uses [ SwiftFormat] ( https://github.com/nicklockwood/SwiftFormat ) to maintain consistent code formatting.
65+
66+ #### Installation
67+
68+ Install SwiftFormat using Homebrew:
69+
70+ ``` bash
71+ brew install swiftformat
72+ ```
73+
74+ #### Pre-commit Hook Setup
75+
76+ To automatically format your code before each commit, set up the pre-commit hook:
77+
78+ ``` bash
79+ # Navigate to the repository root
80+ cd /path/to/ios-client
81+
82+ # Make the pre-commit hook executable
83+ chmod +x scripts/git-hooks/pre-commit
84+
85+ # Create a symbolic link to the pre-commit hook
86+ git config core.hooksPath scripts/git-hooks
87+ ```
88+
6089## License
6190Licensed under the Apache License, Version 2.0. See: [ Apache License] ( http://www.apache.org/licenses/ ) .
6291
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Path to SwiftFormat binary
4+ SWIFT_FORMAT=$( which swiftformat)
5+
6+ # Check if SwiftFormat is installed
7+ if [ -z " $SWIFT_FORMAT " ]; then
8+ echo " error: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat"
9+ echo " or install via brew: brew install swiftformat"
10+ exit 1
11+ fi
12+
13+ # Get list of Swift files that are staged for commit
14+ FILES=$( git diff --cached --name-only --diff-filter=ACMR | grep " \.swift$" )
15+
16+ if [ -n " $FILES " ]; then
17+ echo " Running SwiftFormat on staged Swift files..."
18+ echo " $FILES " | xargs " $SWIFT_FORMAT " --config .swiftformat
19+
20+ # Add back the formatted files to staging
21+ echo " $FILES " | xargs git add
22+ fi
23+
24+ exit 0
You can’t perform that action at this time.
0 commit comments