✨ feat(pr-autocreate): refuse a push to a retired branch, 0.6.18
Merged
AT
16d ago+295+295+012345678901234567890123456789-23-23-01234567890123456789
Slice: #327
athya_mono's pr-autocreate.py gained a fourth mode, refuse-retired, after niyam 0.6.17 was cut. It came in athya-hq/athya_mono#3664 (0165 L-04). This slice moves that file to niyam, and athya_mono deletes its copy only once niyam refuses the same planted mistake. So the mode comes over here, released as 0.6.18.
What changes
niyam pr-autocreate refuse-retired --root <repo> --remote <name>. The pre-push hook runs it before its expensive checks, with git's ref lines on stdin.- It refuses (exit 3) a push to a branch whose PR merged while none is open. Pushing such a branch recreates what the merge retired, and the commits after the merge land in no PR.
- The refusal names the way out. That is the new
retiresetting, a command with{number}, or else theretiredpage. - It judges no deletion, tag, protected or queue branch, other remote, or CI push.
- It fails open, as athya's does. A GitHub error, or a full page of 20 PRs (counted before the head filter, so other heads filling the page count too), only warns.
- A crash, bad arguments or unreadable settings exit 4 ("not checked"), never the 0 of a live branch.
- One rule.
retiredByis shared byensurePrand the new mode.Pulls.listingreturns the pulls and whether the page was full, andPulls.listwraps it. pushedRefsreads the ref lines forspawn-watchersandrefuse-retiredalike.- Docs and version. README, pr-autocreate section, and 0.6.18 in
package.jsonand the install link.
Evidence
node --test src/pr-autocreate.test.ts: 70 pass, 9 of them new:- the L-04 refusal and its message;
- the
retireandretiredway-out lines; - live branches (open after merged, closed unmerged, none);
- pushes it doesn't judge, asking GitHub nothing;
- one ask per branch;
- a 502, a full page, and a full page made of other heads;
- exit 4 on bad arguments, settings, or a crash;
retiredByandpushedRefs.
pnpm checkpasses. Coverage is 99.65 / 97.47 / 98.83 (lines / branches / functions).node dist/cli.js --versionprints 0.6.18.- Parity with athya_mono's
refuse_retired:- same refs judged, same CI and remote exemption;
- same exit codes (3 refuse, 4 crash);
- the first two message lines are word for word.
State #328 ("Release ships pr-autocreate") stays open until athya_mono pins this release, in athya-hq/athya_mono#3646.
🤖 Generated with Claude Code
Summary by cubic
Adds refuse-retired mode to niyam pr-autocreate so the pre-push hook refuses pushes to branches whose PR already merged while none is open. The refusal names the way out, from the new retire setting or the existing retired page. Bumps the package to 0.6.18.
- Exits 3 on refusal; GitHub errors and a full page of PRs only warn; crashes exit 4, never the 0 of a live branch.
- Deletions, tags, protected branches, other remotes, and CI pushes pass without asking GitHub.
ensurePrand the new mode share oneretiredByrule;pushedRefsreads the ref lines for bothspawn-watchersandrefuse-retired.retiremust name the merged PR as{number}; adopter moves the commits missing from the PR head to a fresh branch.