Merge rust-bitcoin/rust-bitcoin#2980: just: install/remove git hooks
1b0653314b
just: install/remove git hooks (Ryan Breen) Pull request description: Added `just install-git-hooks` and `just remove-git-hooks` (with contrib script). Fix: #2599 ACKs for top commit: Kixunil: ACK1b0653314b
tcharding: ACK1b0653314b
Tree-SHA512: fa11eb3429a91928de43be94223862fd1805b7328a61e098cf3fad89fd6df4f6818eaa4b2eeea432e1f0b16c6df12c5fcca66389236af915113d49f1ac2741f8
This commit is contained in:
commit
ac490bf347
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