feat: add --auto-merge flag to merge PR/MR and close git issues #39

Merged
david merged 2 commits from issue-38/add-auto-merge-flag into main 2026-07-29 01:38:58 +00:00
Owner

Summary

Add the --auto-merge flag to pi-loop, enabling automatic PR/MR merge after creation and source issue close.

Changes

  • M1: Configuration & CLI flag (--auto-merge, PILOOP_AUTO_MERGE, timeout/poll env vars)
  • M2: Issue close clients (Forgejo/GitHub/GitLab REST, Jira no-op)
  • M3: Merge polling abstraction (MergePoller interface, ForgejoMergePoller, pollUntilMergeable)
  • M4: Wire auto-merge into MR stage (non-draft creation, poll, merge, MrResult.autoMerge)
  • M5: Orchestrator wiring & issue close (non-fatal close failures)
  • M6: Outcome-aware write-back (comment reflects draft/merged/merge-failed)
  • M7: Schema, artifacts, and final summary (autoMerge validation, summary status)
  • M8: GitHub/GitLab merge polling (gh/glab CLI pollers and factory)
  • M9: Gated E2E test for Forgejo auto-merge and documentation updates

Files changed

  • 96 files (+4337/-274 lines)
  • 16 new files (pollers, close clients, E2E test, docs)

Testing

  • All 768 unit tests pass
  • Lint clean
  • Format clean
  • Gated E2E (PILOOP_E2E=1 npm run e2e) — requires live Forgejo sandbox
## Summary Add the `--auto-merge` flag to pi-loop, enabling automatic PR/MR merge after creation and source issue close. ## Changes - **M1**: Configuration & CLI flag (`--auto-merge`, `PILOOP_AUTO_MERGE`, timeout/poll env vars) - **M2**: Issue close clients (Forgejo/GitHub/GitLab REST, Jira no-op) - **M3**: Merge polling abstraction (`MergePoller` interface, `ForgejoMergePoller`, `pollUntilMergeable`) - **M4**: Wire auto-merge into MR stage (non-draft creation, poll, merge, `MrResult.autoMerge`) - **M5**: Orchestrator wiring & issue close (non-fatal close failures) - **M6**: Outcome-aware write-back (comment reflects `draft`/`merged`/`merge-failed`) - **M7**: Schema, artifacts, and final summary (autoMerge validation, summary status) - **M8**: GitHub/GitLab merge polling (`gh`/`glab` CLI pollers and factory) - **M9**: Gated E2E test for Forgejo auto-merge and documentation updates ## Files changed - 96 files (+4337/-274 lines) - 16 new files (pollers, close clients, E2E test, docs) ## Testing - [x] All 768 unit tests pass - [x] Lint clean - [x] Format clean - [ ] Gated E2E (`PILOOP_E2E=1 npm run e2e`) — requires live Forgejo sandbox
Implement issue #38: full auto-merge pipeline with 9 milestones:

M1: Configuration & CLI flag (--auto-merge, PILOOP_AUTO_MERGE, timeout/poll)
M2: Issue close clients (Forgejo/GitHub/GitLab/Jira no-op)
M3: Merge polling abstraction (MergePoller interface, Forgejo poller, pollUntilMergeable)
M4: Wire auto-merge into MR stage (non-draft creation, poll, merge, MrResult.autoMerge)
M5: Orchestrator wiring & issue close (non-fatal close failures)
M6: Outcome-aware write-back (comment reflects draft/merged/merge-failed)
M7: Schema, artifacts, and final summary (autoMerge validation, summary status)
M8: GitHub/GitLab merge polling (gh/glab CLI pollers and factory)
M9: Gated E2E for Forgejo and documentation updates

768 tests pass, lint clean.
Critical:
- Pass repoRoot as 4th argument to createMergePoller in runAutoMerge

Major:
- Update test to assert repoRoot is forwarded to merge poller factory
- Extract shared authenticated HTTP request factory (makeAuthenticatedRequest)
  and refactor all 5 HTTP clients to use it (ForgejoMrClient, ForgejoIssueClient,
  ForgejoMergePoller, GitHubIssueClient, GitLabIssueClient)
- Extract shared CLI poller base (makeCliRunner) from GitHub/GitLab merge pollers
- Document hardcoded --merge strategy in GitHubMergePoller
- Add log line before auto-merge-failed error is thrown
- Make auto-merge-timeout retriable in classifyError

Minor:
- Rename sleep() to delay() in pollUntilMergeable
- Simplify extractMrNumber regex terminators to [^0-9]|$
- Use explicit outcome suffix templates in formatWritebackSummary
- Simplify draft adjective logic in buildMrUserPrompt with mrType variable

Suggestions:
- Add comprehensive JSDoc to MergePoller interface
- Extract shared encodeRepo utility from 3 Forgejo classes
- Add unit tests for CLI runner, authenticated fetch, and encodeRepo
david force-pushed issue-38/add-auto-merge-flag from 1bda4ebc7e to 57ec81a5fa 2026-07-29 01:36:17 +00:00 Compare
david merged commit f2175183ec into main 2026-07-29 01:38:58 +00:00
david deleted branch issue-38/add-auto-merge-flag 2026-07-29 01:38:59 +00:00
Sign in to join this conversation.
No reviewers
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
david/pi-loop!39
No description provided.