just: install/remove git hooks
This commit is contained in:
parent
6c8f759676
commit
1b0653314b
10
README.md
10
README.md
|
@ -185,14 +185,8 @@ fixing `act` issues.
|
|||
|
||||
### Githooks
|
||||
|
||||
To assist devs in catching errors _before_ running CI we provide some githooks. If you do not
|
||||
already have locally configured githooks you can use the ones in this repository by running, in the
|
||||
root directory of the repository:
|
||||
```
|
||||
git config --local core.hooksPath githooks/
|
||||
```
|
||||
|
||||
Alternatively add symlinks in your `.git/hooks` directory to any of the githooks we provide.
|
||||
To assist devs in catching errors _before_ running CI we provide some githooks. Copy the hooks in `githooks/`
|
||||
to your githooks folder or run `just githooks-install` to copy them all.
|
||||
|
||||
## Policy on Altcoins/Altchains
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GIT_DIR=$(git rev-parse --git-common-dir)
|
||||
HOOKS_DIR=$(git config --get core.hooksPath || echo "$GIT_DIR/hooks")
|
||||
|
||||
remove_githooks() {
|
||||
for hook in githooks/*
|
||||
do
|
||||
bn=$(basename "$hook")
|
||||
echo "Removing githook $bn"
|
||||
rm "$HOOKS_DIR/$bn"
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
|
||||
add_githooks() {
|
||||
mkdir -p "$HOOKS_DIR"
|
||||
cp -i githooks/* "$HOOKS_DIR"
|
||||
exit 0
|
||||
}
|
||||
|
||||
while getopts "r" flag; do
|
||||
case $flag in
|
||||
r) remove_githooks
|
||||
;;
|
||||
*) exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
add_githooks # Copy githooks by default (no options provided)
|
Loading…
Reference in New Issue