feat(gitea): Gitea/Forgejo adapter for v1 operations #27

Merged
deadstyle merged 4 commits from feature/6-gitea-adapter into develop 2026-10-02 12:32:02 -05:00
Owner

Summary

The Gitea/Forgejo adapter for v1 (#6). lazyforge can now talk to a real Forgejo or Gitea host: sign in, list repos with your access level, read and merge PRs, read and edit issues, comment, close, list releases, and on Forgejo, list Actions runs, jobs and logs.

Changes

  • internal/forge/gitea: implements the Forge interface on a thin hand-written net/http client (ADR 0005).
    • New calls /version and /user. A version containing +gitea- means Forgejo.
    • Repos come from /user/repos, newest activity first, with permissions mapped to access levels.
    • Pagination: limit=50, always sends page, and stops on the total or an empty page.
    • Merge always sends the PR's head commit. A "head out of date" 409 becomes the head-changed error, so a stale screen can't merge code you didn't see. With no method given, it uses the repo's default merge style.
    • Forgejo Actions: runs, jobs and logs. On Gitea, runs and logs report as unavailable.
  • Recorded API fixtures (13) for tests, plus testdata/README.md on how they were captured. All were captured read-only.
  • docs/architecture.md: the API mapping is marked as verified against Forgejo 16.0.5+gitea-1.22.0.

Test plan

  • The shared Forge contract suite runs against the adapter on a fixture-backed test server, plus adapter-specific tests.
  • Mutation check: 89 one-at-a-time mutations. Five escaped at first (push access, PR labels, closed issue state, a missing total-stop, a missing sort). The tests were strengthened, and every mutation is now caught.
  • make check exit 0 after rebasing onto develop: format, lint, go test -race, govulncheck, build, install test.

Rulings

  • The test-writer owns all fixtures and the test server, and the implementer owns production code.
  • The jobs endpoint isn't paginated. This was verified live (it returns a bare array and ignores limit), so the test server doesn't require page there.

Closes #6

🤖 Generated with Claude Code

## Summary The Gitea/Forgejo adapter for v1 (#6). lazyforge can now talk to a real Forgejo or Gitea host: sign in, list repos with your access level, read and merge PRs, read and edit issues, comment, close, list releases, and on Forgejo, list Actions runs, jobs and logs. ## Changes - `internal/forge/gitea`: implements the `Forge` interface on a thin hand-written `net/http` client (ADR 0005). - `New` calls `/version` and `/user`. A version containing `+gitea-` means Forgejo. - Repos come from `/user/repos`, newest activity first, with permissions mapped to access levels. - Pagination: `limit=50`, always sends `page`, and stops on the total or an empty page. - Merge always sends the PR's head commit. A "head out of date" 409 becomes the head-changed error, so a stale screen can't merge code you didn't see. With no method given, it uses the repo's default merge style. - Forgejo Actions: runs, jobs and logs. On Gitea, runs and logs report as unavailable. - Recorded API fixtures (13) for tests, plus `testdata/README.md` on how they were captured. All were captured read-only. - `docs/architecture.md`: the API mapping is marked as verified against Forgejo `16.0.5+gitea-1.22.0`. ## Test plan - The shared Forge contract suite runs against the adapter on a fixture-backed test server, plus adapter-specific tests. - Mutation check: 89 one-at-a-time mutations. Five escaped at first (push access, PR labels, closed issue state, a missing total-stop, a missing sort). The tests were strengthened, and every mutation is now caught. - `make check` exit 0 after rebasing onto develop: format, lint, `go test -race`, govulncheck, build, install test. ## Rulings - The test-writer owns all fixtures and the test server, and the implementer owns production code. - The jobs endpoint isn't paginated. This was verified live (it returns a bare array and ignores limit), so the test server doesn't require `page` there. Closes #6 🤖 Generated with [Claude Code](https://claude.com/claude-code)
New connects (version + user), Gate blocks Actions on Gitea, and the
adapter implements Forge, Approver, RunLister and LogReader with one
request helper, one status-to-sentinel mapping and one page walker.
architecture.md: Gitea/Forgejo column verified against Forgejo 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Red-first: the gitea package does not exist yet, so these fail to compile
until the adapter lands.

#6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #6

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test(gitea): cover push access, labels, closed issue state, repo order
All checks were successful
ci / check (pull_request) Successful in 55s
3b6c3307b7
Mutation check found these four behaviors unasserted.

#6

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
deadstyle merged commit cfc83977af into develop 2026-10-02 12:32:02 -05:00
deadstyle deleted branch feature/6-gitea-adapter 2026-10-02 12:32:02 -05:00
Sign in to join this conversation.
No description provided.