Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add Gitea forge implementation (3/3)#134

Merged
cesarferreira merged 7 commits into
cesarferreira:mainfrom
geoHeil:feat/forge-gitea
Mar 25, 2026
Merged

feat: add Gitea forge implementation (3/3)#134
cesarferreira merged 7 commits into
cesarferreira:mainfrom
geoHeil:feat/forge-gitea

Conversation

@geoHeil

@geoHeil geoHeil commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds GiteaClient implementing the ForgeClient interface for Gitea pull requests
  • Supports creating, updating, merging PRs, stack comment management via issue comments, and CI status
  • Adds AuthorizationToken auth style and patch_json helper to forge/mod.rs
  • Integration tests for submit (comment/body/both/off modes) and merge/merge-when-ready with PR retargeting

This is PR 3 of 3, splitting #100 into reviewable increments.

Merge order: #132#133 → this. This PR includes PR 1+2's changes and should be merged last.

Stack:

Test plan

  • All 164 integration tests pass (154 existing + 5 GitLab + 5 Gitea tests)
  • All 358 unit tests pass
  • Zero compiler warnings

🤖 Generated with Claude Code

@geoHeil geoHeil force-pushed the feat/forge-gitea branch 7 times, most recently from 6c71f62 to fde8ce5 Compare March 25, 2026 06:20
@cesarferreira

Copy link
Copy Markdown
Owner

I merged the 2/3 PR but now this one has conflicts with your previous PR it seems like, can you just quickly rebase and we can finish this PR stack ;)

@geoHeil

geoHeil commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

let me rebase.

this was exactly my question: I am unaware of a stacking approach for forks/PRs is something like that possible?

geoHeil and others added 7 commits March 25, 2026 10:55
Add GiteaClient implementing the ForgeClient interface for Gitea
pull request operations. Supports creating, updating, merging PRs,
stack comment management via issue comments, and CI status checks.

Key additions:
- src/forge/gitea.rs with full Gitea API v1 client
- AuthorizationToken auth style and patch_json helper in forge/mod.rs
- Integration tests for submit (comment/body/both/off modes) and
  merge/merge-when-ready with PR retargeting

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…nation limits

- Fix is_pr_merged() to check only the `merged` field instead of also
  treating closed PRs as merged (a closed PR may have been rejected)
- Add limit=50 to all Gitea list API calls (pulls, comments, statuses)
  to avoid silent truncation at Gitea's default page size of 30

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Map raw Gitea status strings to normalized conclusions:
success->success, failure/error->failure. This matches the GitLab
normalization pattern so downstream consumers get consistent values.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Pagination parameters only apply to GET requests. The limit=50 was
accidentally added to the POST endpoint by a bulk replace.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…nings

- Fix aggregate CI overall status: failure now takes priority over
  pending. Previously find_map short-circuited on the first non-success
  status, so [pending, failed] would report "pending" instead of
  "failure". Both GitLab and Gitea clients affected.
- Replace GitHub-specific auth check in ci.rs with forge_token() so
  `stax ci` works on GitLab/Gitea repos.
- Replace hardcoded "GitHub" in user-facing error messages (submit.rs,
  ci.rs) with forge-generic wording.
- Rename API stats labels from "github.api.*" to "forge.api.*".
- Add eprintln warnings when reviewers/labels/assignees are requested
  on forges that don't support them (were silent no-ops).
- Add Display impl for ForgeType.
- Add unit tests for aggregate_ci_overall priority logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Fix MergePullRequest serialization: Gitea API expects PascalCase
  "MergeTitleField" but we were sending snake_case "merge_title_field",
  causing squash merge commit titles to be silently ignored.
- Recognize Forgejo (popular Gitea fork) in forge detection so
  self-hosted Forgejo instances use the Gitea client automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Two bugs:

1. test_submit_gitea_comment_mode_creates_pull_and_issue_comment was
   missing the #[tokio::test] attribute, so the test runner never
   executed it (same class of bug as the GitLab one).

2. Gitea's API returns state="closed" for merged PRs (with a separate
   merged=true field), so pr.state.to_uppercase() produced "CLOSED"
   instead of "MERGED". This broke sync's metadata-based merge
   detection (sync.rs:1133 checks for state "MERGED").

   Added normalize_gitea_state() that checks the merged field first,
   mirroring GitLab's normalize_gitlab_state() approach.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@cesarferreira cesarferreira merged commit 9b718bc into cesarferreira:main Mar 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants