feat(forge): search pull requests and issues, pr close and reopen, pr view --body and --json #6

Open
HumanBean wants to merge 1 commit from HumanBean/Tooling:forge-search-close-body into main
Owner

Why

An agent spent hours on a change that another contributor already had open as a WIP pull request: pr list shows only titles, and nothing searched the descriptions. A superseded PR could only be commented on, not closed, and editing a description meant calling the API by hand to get its raw text. These are the missing commands, for every repository forge.py works on.

What changed

  • search WORD|"A PHRASE" ... [--state open|closed|all] [--mine] [--limit N]: pull requests and issues whose title or description has every word (any case), with number, PR or issue, state (open, wip, merged, closed), author, title and the matching line. It lists the items and matches locally, since Forgejo's indexer missed results.
  • pr close N (--comment TEXT | --comment-file F) [--force] posts the reason, then closes; someone else's PR needs --force. pr reopen N [--comment ...] opens a closed one (not a merged one).
  • pr view N --body prints the description exactly as stored (CRLF kept); --json prints its fields.
  • Hints use command(); docs in docs/forge.md (new Search before building section); tests in tests/test_forge_pr.py and a new tests/test_forge_search.py.

Ported from Longshot's pull request Longshot#831 by zeldaootr, now that forge.py lives here (Tooling#1, Longshot#915). The port keeps their behavior and tests; only the paths, the repository (global REPO) and the hint text differ.

Testing

No tests were run on this PC (not tests/run_all.py, not a single check, and no calls against the forge). The tests ported with the change passed for the author on Longshot; they still need a run here: python -I -B tests/run_all.py.

🤖 Generated with Claude Code

## Why An agent spent hours on a change that another contributor already had open as a WIP pull request: `pr list` shows only titles, and nothing searched the descriptions. A superseded PR could only be commented on, not closed, and editing a description meant calling the API by hand to get its raw text. These are the missing commands, for every repository `forge.py` works on. ## What changed - `search WORD|"A PHRASE" ... [--state open|closed|all] [--mine] [--limit N]`: pull requests and issues whose title or description has every word (any case), with number, PR or issue, state (open, wip, merged, closed), author, title and the matching line. It lists the items and matches locally, since Forgejo's indexer missed results. - `pr close N (--comment TEXT | --comment-file F) [--force]` posts the reason, then closes; someone else's PR needs `--force`. `pr reopen N [--comment ...]` opens a closed one (not a merged one). - `pr view N --body` prints the description exactly as stored (CRLF kept); `--json` prints its fields. - Hints use `command()`; docs in `docs/forge.md` (new *Search before building* section); tests in `tests/test_forge_pr.py` and a new `tests/test_forge_search.py`. Ported from Longshot's pull request [Longshot#831](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/831) by zeldaootr, now that `forge.py` lives here (Tooling#1, Longshot#915). The port keeps their behavior and tests; only the paths, the repository (global `REPO`) and the hint text differ. ## Testing No tests were run on this PC (not `tests/run_all.py`, not a single check, and no calls against the forge). The tests ported with the change passed for the author on Longshot; they still need a run here: `python -I -B tests/run_all.py`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`forge.py search WORD|"A PHRASE" ...` lists the pull requests and issues whose title or description has every word
(any case), with state, author and the matching line, so a change already open as a WIP PR is found before it is built.
`pr close N --comment ...` closes a PR saying why (someone else's needs --force), `pr reopen N` opens a closed one,
`pr view N --body` prints the description exactly as stored (to edit and put back), `--json` its fields.
Works for any repository forge.py is pointed at.

Ported from Longshot#831 by zeldaootr: MagicBeanDev/Longshot#831
Hints use command(); new tests/test_forge_search.py. No tests were run on this PC.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'forge-search-close-body:HumanBean-forge-search-close-body'
git switch 'HumanBean-forge-search-close-body'
Sign in to join this conversation.
No reviewers
No labels
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Tooling!6
No description provided.