-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
export PATH="$PATH:/opt/homebrew/bin" | ||
|
||
regex="\(Mlem/.*\).swift$" | ||
formatter=$(which swiftformat) | ||
|
||
check_for_swiftformat() { | ||
if [ ! -x "$formatter" ] | ||
then | ||
1>&2 echo "Unable to find swiftformat - no formatting will take place" | ||
exit 0 | ||
fi | ||
} | ||
|
||
format_staged_files() { | ||
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do | ||
$formatter "${line}" | ||
git add "$line" | ||
done | ||
} | ||
|
||
main() { | ||
check_for_swiftformat | ||
format_staged_files | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--wraparguments before-first | ||
--commas inline | ||
--disable wrapMultilineStatementBraces | ||
--trimwhitespace nonblank-lines | ||
--self init-only | ||
--stripunusedargs closure-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
brew "swiftlint" | ||
brew "swiftformat" |