mirror of
https://github.com/taigrr/hooks.git
synced 2026-04-01 19:08:53 -07:00
ci: add shellcheck workflow, install/uninstall scripts
This commit is contained in:
23
.github/workflows/shellcheck.yml
vendored
Normal file
23
.github/workflows/shellcheck.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: ShellCheck
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install ShellCheck
|
||||
run: sudo apt-get install -y shellcheck
|
||||
|
||||
- name: Run ShellCheck on all hooks
|
||||
run: |
|
||||
shellcheck pre-commit commit-msg pre-push post-checkout post-commit post-merge
|
||||
39
README.md
39
README.md
@@ -39,42 +39,39 @@ a couple of annoying blunders:
|
||||
|
||||
## Installation
|
||||
|
||||
### Quick Install
|
||||
### Quick Install (recommended)
|
||||
|
||||
```bash
|
||||
git clone https://github.com/taigrr/hooks.git ~/.git-hooks
|
||||
git config --global core.hooksPath ~/.git-hooks
|
||||
cd ~/.git-hooks && ./install.sh
|
||||
```
|
||||
|
||||
This sets `core.hooksPath` so **all** repos use these hooks. Updates to the
|
||||
hooks directory apply everywhere immediately.
|
||||
|
||||
To override hooks for a specific repo:
|
||||
|
||||
```bash
|
||||
cd /path/to/repo
|
||||
git config core.hooksPath /path/to/other/hooks
|
||||
```
|
||||
|
||||
### Template Installation
|
||||
|
||||
Use this if you want new repos to get a *copy* of the hooks at clone/init time:
|
||||
Use this if you only want **new** repos (created with `git init` or `git clone`)
|
||||
to receive a copy of these hooks:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/taigrr/hooks.git ~/.git-hooks
|
||||
git config --global init.templatedir ~/.git-hooks
|
||||
cd ~/.git-hooks && ./install.sh --template
|
||||
```
|
||||
|
||||
> **Note:** Existing repos won't be affected — only newly cloned or initialized repos
|
||||
> will receive the hooks.
|
||||
> **Note:** Existing repos won't be affected.
|
||||
|
||||
### Central Management Installation
|
||||
|
||||
Use this if you want *all* repos (existing and new) to use the same hooks directory:
|
||||
### Uninstall
|
||||
|
||||
```bash
|
||||
git clone https://github.com/taigrr/hooks.git ~/.git-hooks
|
||||
git config --global core.hooksPath ~/.git-hooks
|
||||
```
|
||||
|
||||
This has the benefit of updating the hooks for all repos when you make a change,
|
||||
instead of only new repos going forward, but will require you to specify manual
|
||||
overrides for individual repos with customized hooks:
|
||||
|
||||
```bash
|
||||
# Override for a specific repo
|
||||
cd /path/to/repo
|
||||
git config core.hooksPath /path/to/other/hooks
|
||||
cd ~/.git-hooks && ./uninstall.sh
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
18
install.sh
Executable file
18
install.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install git hooks globally via core.hooksPath.
|
||||
# Usage: ./install.sh [--template]
|
||||
# --template Use init.templateDir instead (only affects new repos)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
hook_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
if [ "${1:-}" = "--template" ]; then
|
||||
git config --global init.templateDir "$hook_dir"
|
||||
echo "Installed: init.templateDir set to $hook_dir"
|
||||
echo "New repos created with git init/clone will copy these hooks."
|
||||
else
|
||||
git config --global core.hooksPath "$hook_dir"
|
||||
echo "Installed: core.hooksPath set to $hook_dir"
|
||||
echo "All repos will use hooks from $hook_dir."
|
||||
fi
|
||||
17
uninstall.sh
Executable file
17
uninstall.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Remove global git hooks configuration set by install.sh.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if git config --global --get core.hooksPath > /dev/null 2>&1; then
|
||||
git config --global --unset core.hooksPath
|
||||
echo "Removed core.hooksPath"
|
||||
elif git config --global --get init.templateDir > /dev/null 2>&1; then
|
||||
git config --global --unset init.templateDir
|
||||
echo "Removed init.templateDir"
|
||||
else
|
||||
echo "No global hooks configuration found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Global hooks configuration cleared."
|
||||
Reference in New Issue
Block a user