Skip to content

git-story: register git pre-commit hook - #3103

Closed
Dominic Nguyen (datduyng) wants to merge 2 commits into
domnguyen/git-storyfrom
domnguyen/git-story-git-hooks
Closed

Dominic Nguyen (datduyng) wants to merge 2 commits into
domnguyen/git-storyfrom
domnguyen/git-story-git-hooks

Conversation

@datduyng

Copy link
Copy Markdown
Contributor

Stacked on #3101.

git story init now also writes a pre-commit script to the git hooks directory. The script runs exec git story hooks git pre-commit "$@", so git's hook arguments and stdin reach the command unchanged. The handler reads stdin and prints a placeholder.

  • Honors core.hooksPath and worktrees via git rev-parse --git-path.
  • Does not overwrite a hook it did not write (marker line); exits 1 and reports it.

Verified in a temp repo: commit fires the hook; echo piped | .git/hooks/pre-commit a b prints args=["a","b"] stdin="piped\n"; re-run is idempotent; foreign hook is skipped.

@datduyng

Copy link
Copy Markdown
Contributor Author

Split into #3104 (hook + init) and the test PR stacked on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant