Add commit message normalizer hook and install script
- scripts/normalize-commit-msg.js: capitalizes subject, strips trailing period, trims whitespace, warns when subject > 72 chars - scripts/commit-msg: shell wrapper symlinked into .git/hooks/commit-msg - scripts/install-hooks.sh: contributor setup script (sh scripts/install-hooks.sh) - scripts/package.json: test runner + hooks:install npm script - scripts/__tests__/normalize-commit-msg.test.js: 15 unit tests Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
This commit is contained in:
34
scripts/install-hooks.sh
Executable file
34
scripts/install-hooks.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# install-hooks.sh
|
||||
# Installs the project's git hooks into .git/hooks/.
|
||||
# Run this once after cloning: sh scripts/install-hooks.sh
|
||||
|
||||
set -e
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
HOOKS_DIR="$REPO_ROOT/.git/hooks"
|
||||
SCRIPTS_DIR="$REPO_ROOT/scripts"
|
||||
|
||||
install_hook() {
|
||||
local name="$1"
|
||||
local src="$SCRIPTS_DIR/$name"
|
||||
local dst="$HOOKS_DIR/$name"
|
||||
|
||||
if [ ! -f "$src" ]; then
|
||||
echo "install-hooks: source not found: $src" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -f "$dst" ] && [ ! -L "$dst" ]; then
|
||||
echo "install-hooks: warning: $dst already exists and is not a symlink — skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
ln -sf "$src" "$dst"
|
||||
chmod +x "$src"
|
||||
echo "install-hooks: installed $name -> $dst"
|
||||
}
|
||||
|
||||
install_hook "commit-msg"
|
||||
|
||||
echo "install-hooks: done"
|
||||
Reference in New Issue
Block a user