This will add a new file .shusky.yml in your root with the following configuration:
pre-push:
- echo "Shusky is ready, please configure .shusky.yml"
pre-commit:
- echo "Shusky is ready, please configure .shusky.yml"
NOTE: Shusky installation is safe, it will not remove any previous content in your git hooks file.
it only will add the command for running shusky. More info in Advanced installation.
How to use
Only need to add your commands in .shusky.yml configuration file. For example:
pre-push:
- set -o pipefail && swift test 2>&1 | xcpretty --color
pre-commit:
- swift run -c release swiftformat .
- swift run -c release swiftlint lint .
- git add -A
If you add a new hook you must run againshusky install. For example:
pre-push:
- set -o pipefail && swift test 2>&1 | xcpretty --color
pre-commit:
- swift run -c release swiftformat .
- swift run -c release swiftlint lint .
- git add -A
pre-merge-commit:
- swift test
Maybe you want to run SPM binaries, but you always have to remember to run swift run for compiling the binary. Don’t worry, using swift-run option, shusky will handle it for you.
pre-commit:
- swift-run:
command: swiftformat .
You can add especial behaviour to commands using the key run. For example you can set non-verbose to commands. Then only wil display output result only if the command fails. For example:
pre-commit:
- swift run -c release swiftformat .
- swift run -c release swiftlint lint .
- run:
command: set -o pipefail && swift test 2>&1 | xcpretty --color
verbose: false
- git add -A
Maybe while you’re developing you don’t want to cancel the git commit if one of the commands fail. So you can set propierty critical to false.
In this example, if swiftlint fails will keep going with the commit:
pre-commit:
- swift run -c release swiftformat .
- run:
command: swift run -c release swiftlint lint .
critical: false
- git add -A
Shusky
Table of Contents
Overview
Shusky is a port of Husky to Swift which allow to execute git hooks with Swift. Can prevent
git commit
andgit push
.Features
git commit
,git push
…git
command execution.SKIP_SHUSKY
. For example:SKIP_SHUSKY=1 git commit -m
.swift run
command for you.Install
Add the following code to your
Package.swift
file.Then:
If you have your
Package.swift
file in the root, run:If you have your
Package.swift
file to another path, run:This will add a new file
.shusky.yml
in your root with the following configuration:NOTE: Shusky installation is safe, it will not remove any previous content in your git hooks file. it only will add the command for running shusky. More info in Advanced installation.
How to use
Only need to add your commands in
.shusky.yml
configuration file. For example:If you add a new hook you must run again
shusky install
. For example:Maybe you want to run SPM binaries, but you always have to remember to run
swift run
for compiling the binary. Don’t worry, usingswift-run
option, shusky will handle it for you.You can add especial behaviour to commands using the key
run
. For example you can set non-verbose to commands. Then only wil display output result only if the command fails. For example:Maybe while you’re developing you don’t want to cancel the
git commit
if one of the commands fail. So you can set propiertycritical
tofalse
. In this example, ifswiftlint
fails will keep going with the commit:NOTE: More info in Advanced configurations
Uninstall
Run: