Skip to content

fix(hook): scope enforce_gh_english to this repository - #404

Merged
ycpss91255 merged 2 commits into
mainfrom
fix/scope-gh-english-hook
Sep 19, 2026
Merged

ycpss91255 merged 2 commits into
mainfrom
fix/scope-gh-english-hook

Conversation

@ycpss91255

Copy link
Copy Markdown
Owner

Summary

Scope the enforce_gh_english.sh PreToolUse hook to this repository.

.agents/hook/enforce_gh_english.sh now allows early when a gh issue|pr create|comment command demonstrably targets another repository:

  • an explicit --repo <ref> / -R <ref> / --repo=<ref> naming a repo other than this one (owner/name, host/owner/name, https/ssh URL, git@host:owner/name, optional .git and quotes are normalised to lower-case owner/name), else
  • $GH_REPO, else
  • the origin remote of the directory the command runs in (a leading cd <dir> &&, the payload's .cwd, or $PWD) resolving to another repo.

"This repo" is derived from the checkout's git remote get-url origin (a linked worktree shares it), with a literal ycpss91255/initialization fallback when origin is unreadable. An undeterminable target keeps the guard (conservative), and behaviour for this repo is unchanged. .claude/settings.json is untouched.

Why

The same machine now hosts a second repo (ycpss91255/worktool) whose issues and PRs are written in zh-TW, and its gh --repo ycpss91255/worktool ... commands run from this repo's cwd, so this repo's PreToolUse Bash hooks fire on them and the English-only hook denied their CJK bodies. The English-only rule is this repository's rule, not the host's.

Test plan

TDD: six cases were added to test/unit/hook/enforce_gh_english_spec.bats first and run in Docker against the unchanged hook (RED), then the scoping was implemented (GREEN).

RED (before the change):

not ok 9 allows CJK when --repo names another repository
not ok 10 allows CJK when -R names another repository
not ok 11 allows CJK when --repo=<other> (equals form) names another repository
ok 12 still denies CJK when --repo names this repository
ok 13 still denies CJK without --repo inside this repository
not ok 14 allows CJK without --repo when cwd is outside this repository

GREEN (after the change):

ok 9 allows CJK when --repo names another repository
ok 10 allows CJK when -R names another repository
ok 11 allows CJK when --repo=<other> (equals form) names another repository
ok 12 still denies CJK when --repo names this repository
ok 13 still denies CJK without --repo inside this repository
ok 14 allows CJK without --repo when cwd is outside this repository

Gates (Docker):

  • just -f justfile.ci lint
  • just -f justfile.ci test-unit

just -f justfile.ci lint tail:

[ci] Running ShellCheck
[ci]   found 357 shell script(s)
[ci] ShellCheck OK
[ci] Running fish -n syntax check
[ci]   checked 24 fish script(s); 0 failed
[ci] fish syntax OK
[ci] Running Hadolint on dockerfile/Dockerfile.test-tools
[ci] Running Hadolint on dockerfile/Dockerfile.kcov-tools
[ci] Hadolint OK
exit=0

just -f justfile.ci test-unit tail (full unit tree, 1..7499, 7499 ok, 0 not ok):

ok 493 allows CJK when --repo names another repository
ok 494 allows CJK when -R names another repository
ok 495 allows CJK when --repo=<other> (equals form) names another repository
ok 496 still denies CJK when --repo names this repository
ok 497 still denies CJK without --repo inside this repository
...
ok 7498 parity: whiptail accumulator and fzf selstate yield identical install argv
ok 7499 parity: a platform override threads identically into both tiers' argv
exit=0

The same machine hosts a sibling repo (ycpss91255/worktool) whose issues
and PRs are written in zh-TW, and its `gh --repo <other>` calls run from
this repo's cwd, so this PreToolUse Bash hook fired on them and denied
their CJK bodies. The English-only rule is this repository's rule, not
the host's.

The hook now allows early when a `gh issue|pr create|comment` command
demonstrably targets another repository: an explicit --repo / -R /
--repo= naming a repo other than this one (owner/name, host/owner/name,
URL, .git and quoted forms normalised, case-insensitive), else $GH_REPO,
else the origin of the directory the command runs in (`cd <dir> &&`,
payload .cwd, or $PWD). "This repo" is derived from the checkout's
`git remote get-url origin` with a literal ycpss91255/initialization
fallback. An undeterminable target keeps the guard; behaviour for this
repo is unchanged; settings.json untouched.

Tests: six new cases in test/unit/hook/enforce_gh_english_spec.bats
(RED before the change, GREEN after). CHANGELOG entry under
[Unreleased] / Fixed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NX5H2vuMTv4mBmjpPYoS3s
@ycpss91255
ycpss91255 enabled auto-merge (squash) September 19, 2026 10:18
@ycpss91255
ycpss91255 merged commit a97348d into main Sep 19, 2026
19 checks passed
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