-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Commit hook install script (#1845)
Task URL: https://app.asana.com/0/1200194497630846/1205110674679790/f Descrption: Adds a script that allows us to automatically install a pre-commit hook that runs swiftlint --fix The original installation script lives in BSK for easier maintenance. App Scripts download it and install it locally. (Remote URL will be updated once we merge BSK. This script can be extended as necesary to install/manage additional pre-commit hooks
- Loading branch information
1 parent
af145db
commit 4313e81
Showing
3 changed files
with
49 additions
and
1 deletion.
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
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,44 @@ | ||
#!/bin/bash | ||
|
||
FIX=false | ||
|
||
if [[ "$1" == "--fix" ]]; then | ||
FIX=true | ||
fi | ||
|
||
if [[ -n "$CI" ]] || [[ -n "$BITRISE_IO" ]]; then | ||
echo "Skipping SwiftLint run in CI" | ||
exit 0 | ||
fi | ||
|
||
# Add brew into PATH | ||
if [[ -f /opt/homebrew/bin/brew ]]; then | ||
eval $(/opt/homebrew/bin/brew shellenv) | ||
fi | ||
|
||
if test -d "$HOME/.mint/bin/"; then | ||
PATH="$HOME/.mint/bin/:${PATH}" | ||
fi | ||
|
||
export PATH | ||
|
||
|
||
SWIFTLINT_COMMAND="swiftlint lint" | ||
if $FIX; then | ||
SWIFTLINT_COMMAND="swiftlint lint --fix" | ||
fi | ||
|
||
if which swiftlint >/dev/null; then | ||
if [ "$CONFIGURATION" = "Release" ]; then | ||
$SWIFTLINT_COMMAND --strict | ||
if [ $? -ne 0 ]; then | ||
echo "error: SwiftLint validation failed." | ||
exit 1 | ||
fi | ||
else | ||
$SWIFTLINT_COMMAND | ||
fi | ||
else | ||
echo "error: SwiftLint not installed. Install using \`brew install swiftlint\`" | ||
exit 1 | ||
fi |
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,4 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_URL="https://raw.githubusercontent.com/duckduckgo/BrowserServicesKit/main/scripts/pre-commit.sh" | ||
curl -s "${SCRIPT_URL}" | bash -s -- "$@" |