Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Add pre-commit formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
incubo4u committed Dec 21, 2023
1 parent b19ba37 commit 2fdaea9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
swift-format format -i "${line}" --configuration swift-format-config.json;
git add "$line";
done

git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
swift-format lint -s "${line}" --configuration swift-format-config.json || exit 1;
done
swift-format --version 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
echo "${line}"
swift-format -i "${line}"
git add "$line"
done
fi

0 comments on commit 2fdaea9

Please sign in to comment.