Repository navigation
fix(git): repository-local signing key message and TTY guard for the merge tool - #2173
josecelano merged 10 commits into
Conversation
Signing configuration in this estate is per repository: the global Git configuration carries no signing key, so the previous message sent a maintainer to a scope that is deliberately left unset and the preflight would keep failing after they followed it. The check itself is unchanged because 'git config --get' already reads the local scope.
The fixture commits the vendored tool and then deleted it from the working tree, so the wrapper reported an unclean working tree and never reached the vendored-tool check the case exists to assert. Committing the removal restores the intended path; the assertion has never held since the fixture was introduced.
The vendored tool reads its prompts with a plain line read, and its sign and push loops only leave on 's', 'x', or 'push'. With stdin closed, redirected, or otherwise not a terminal, every read returns end of input immediately and those loops reprint their prompt forever, so an unattended run hangs instead of failing. The wrapper now refuses to start it in that case with a message that names the terminal requirement. The guard sits last, immediately before the exec, so the argument, repository, branch, signing-key, vendored-tool, and Python preconditions - and the whole --dry-run path, which never reaches the vendored tool - stay usable from a script. The delegation test runs the wrapper under a pseudo terminal so the contract stays testable from a non-interactive runner.
The prerequisite step configured the signing key globally, which the wrapper's preflight now rejects: signing configuration for this repository is local, and the global scope stays unset. The new guardrail records why the merge tool needs a terminal - its prompts never end at end of input, so an unattended run hangs - and points at --dry-run for non-interactive validation.
Three behaviors of the vendor copy are worth knowing before a merge attempt: a failed comment fetch raises rather than exiting with its own diagnostic, the prompts never end at end of input, and the missing-key message names the global configuration scope. Recording them keeps the copy byte-identical and its provenance hash unchanged, which the local-change policy requires, while the coverage boundary now also names the terminal refusal the tests exercise.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2173 +/- ##
===========================================
- Coverage 84.69% 84.68% -0.02%
===========================================
Files 351 351
Lines 29657 29657
Branches 29657 29657
===========================================
- Hits 25119 25116 -3
- Misses 4184 4189 +5
+ Partials 354 352 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The new test dependency check for script(1) does not verify util-linux flag support (e.g. --command), so the suite can fail non-obviously on systems with BSD script.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refines the repository-local maintainer merge workflow wrapper and its documentation/tests, addressing known rough edges in the vendored github-merge.py without modifying the vendored script itself. It updates signing-key guidance to match repository-local configuration, adds a TTY guard to prevent an infinite prompt loop when stdin is non-interactive, and documents upstream behaviors with verified line references.
Changes:
- Update signing-key guidance (wrapper + skill + tests) to recommend repository-local
git config user.signingkey …rather than--global. - Add an interactive-stdin (TTY) guard to the wrapper to prevent the vendored tool from looping forever on EOF; extend the test suite with a pseudo-terminal helper plus new cases covering the guard and
--dry-run. - Add a “Known Upstream Issues” section documenting upstream behaviors with line-number references and update the stated deterministic test boundary.
File summaries
| File | Description |
|---|---|
| contrib/dev-tools/git/merge-pull-request.sh | Adjusts the signing-key guidance and adds a stdin TTY precondition before invoking the vendored interactive tool. |
| contrib/dev-tools/git/tests/test-merge-pull-request.sh | Updates assertions, adds pseudo-terminal execution support, adds new test cases, and fixes the missing-tool fixture to keep the tree clean. |
| .github/skills/dev/git-workflow/merge-pull-request/SKILL.md | Updates maintainer/agent workflow guidance to match repository-local signing configuration and the new interactive-terminal guardrail. |
| contrib/dev-tools/git/README-github-merge.md | Documents known upstream issues with verified line references and updates the deterministic coverage boundary description. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
ACK 94b1024 |
Summary
The repository-local maintainer merge workflow vendored in #2022 has three rough edges that this PR addresses without touching the vendored
github-merge.py(its provenance hashe390eb01…baad2is unchanged):git config --global user.signingkey. Signing configuration for this repository is repository-local, so both now direct a repository-localgit config user.signingkeyand say the global scope stays unset. The check itself already usedgit config --get, which reads local scope, so only the guidance and the two test assertions that quoted it changed.s,x, orpush, so at end of input (stdin not a terminal, closed, or redirected) it loops forever reprinting its prompt. The wrapper now refuses to start the interactive tool unless stdin is a terminal;--dry-runand every preflight diagnostic keep working non-interactively, because the guard runs last, immediately before theexec.README-github-merge.mdgains a "Known Upstream Issues" section recording, with verified line numbers, the two upstream behaviours above plus a third: a GitHub API failure while fetching PR comments raises aTypeErrorinstead of the intended clean exit.Two things surfaced while adding tests. The wrapper's own deterministic suite (
contrib/dev-tools/git/tests/test-merge-pull-request.sh) was failing at the currentdeveloptip: the missing-tool fixture deleted the vendored file without committing the deletion, so the clean-tree check fired before the assertion the fixture exists to make. That fixture now commits the removal (test(git): keep the missing-tool fixture's working tree clean). Nothing in CI runs this suite, only the skill mentions it, which is why the failure went unnoticed; wiring it into a CI job would be a reasonable follow-up. Secondly, exercising the delegation path now needs a pseudo-terminal, supplied byscript(1)from util-linux; the suite fails fast with a named reason wherescriptis absent (BSDscriptlacks--command).Files touched
contrib/dev-tools/git/merge-pull-request.sh— repository-local signing-key message;require_interactive_stdinguard before theexec.contrib/dev-tools/git/tests/test-merge-pull-request.sh— updated assertions; pseudo-terminal helper; two new cases (non-TTY refusal without invoking the tool,--dry-runstill passing without a terminal); fixture fix..github/skills/dev/git-workflow/merge-pull-request/SKILL.md— repository-local signing prerequisite; interactive-terminal guardrail.contrib/dev-tools/git/README-github-merge.md— "Known Upstream Issues"; coverage sentence lists the terminal refusal.Validation
bash contrib/dev-tools/git/tests/test-merge-pull-request.sh: all 12 cases pass (10 pre-existing, 2 new) in 1.1 s; the non-TTY case was checked for non-vacuity by running the same scenario against the unmodified wrapper, which invoked the stub instead of refusing.shellcheckon both shell files: clean.linter all(torrust-linting 0.2.0): all linters passed (markdownlint, lychee, yamllint, taplo, cspell, clippy, rustfmt, shellcheck).sha256sum contrib/dev-tools/git/github-merge.pymatches the provenance hash recorded in the README.Related to #2022 (already closed; this PR refines the workflow it introduced rather than resolving it).
Documentation follow-ups in this PR
Because the merge tool copies the PR title verbatim into the merge commit subject, two documentation commits ride along:
AGENTS.mdgains a "Pull request titles" note in the Git Workflow section (one Conventional Commits line, no PR number,[#<issue>]only for the issue the PR implements or closes, related or closed issues in the body), and the open-pull-request skill's second title example is aligned to the same bracketed form (docs(agents): [#1697] …instead of a trailing(#1697)).