diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-05-07 09:10:15 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-05-07 09:10:15 -1000 |
| commit | 1fe6fc2b0c5cabf21c241f9a033e4d53dd475316 (patch) | |
| tree | 401cbf51b5c97dad5d72b26f6b51ba7162adee0c | |
| parent | 3a8208bb566f68542ea721eaa0f22a229af9b048 (diff) | |
chore: add pre-commit hook blocking commits to master
Installs scripts/git-hooks/pre-commit which hard-blocks any commit
attempted from the master branch. Activate with:
git config core.hooksPath scripts/git-hooks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | .agent/config.md | 5 | ||||
| -rwxr-xr-x | scripts/git-hooks/pre-commit | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/.agent/config.md b/.agent/config.md index d0e00d1..52d135d 100644 --- a/.agent/config.md +++ b/.agent/config.md @@ -19,9 +19,12 @@ This is the primary source of truth for all AI agents working on **Nav**. These **Before any other action in every session: run `git branch` and switch to `main` if not already there.** ``` -git checkout main # run this if not already on main +git checkout main # run this if not already on main +git config core.hooksPath scripts/git-hooks # activate if not already set ``` +The repo ships a pre-commit hook in `scripts/git-hooks/pre-commit` that hard-blocks commits to `master`. Activate it with the command above on first use in any environment. + **Primary branch: `main`** - ALL work merges to `main`. Never to `master` or any other branch. diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit new file mode 100755 index 0000000..6adba30 --- /dev/null +++ b/scripts/git-hooks/pre-commit @@ -0,0 +1,8 @@ +#!/bin/sh +# Prevent accidental commits to master. All work goes to main. +branch=$(git symbolic-ref --short HEAD 2>/dev/null) +if [ "$branch" = "master" ]; then + echo "ERROR: committing to 'master' is not allowed." >&2 + echo "Switch to 'main' first: git checkout main" >&2 + exit 1 +fi |
