OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Forgejo integration

Open johba37 opened this issue 3 months ago • 8 comments

  • [x] This change is worth documenting at https://docs.all-hands.dev/
  • [x] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

End-user friendly description of the problem this fixes or functionality this introduces. Brings Forgejo (Codeberg/self-hosted) into parity with our GitHub/GitLab integrations so users can browse repos, fetch issues/PRs, and collaborate on Forgejo instances within OpenHands.


Summarize what the PR does, explaining any non-trivial design decisions.

  • Builds on the earlier (stale/closed) effort in https://github.com/All-Hands-AI/OpenHands/pull/8418 to finish Forgejo support.
  • Wires Forgejo into ProviderType, provider mappings, and resolver factories while removing Codeberg-only assumptions via configurable base URLs/env var overrides.
  • Refactors the Forgejo client into a mixin-based architecture (base, branches, repos, features, prs, resolver) matching our GitHub/GitLab layout, which keeps shared HTTP logic isolated and makes future feature work modular.
  • Implements the missing PR operations (create/request reviewers) plus richer resolver helpers (issue/PR comments and grouped review threads).
  • Updates unit tests to exercise the new mixin assembly and PR helpers under both the service layer and resolver factory.

Link of any specific issues this addresses: https://github.com/All-Hands-AI/OpenHands/issues/9354

johba37 avatar Sep 25 '25 11:09 johba37

Great to see this effort continuing to be pursued.

erkinalp avatar Oct 09 '25 14:10 erkinalp

Great to see this effort continuing to be pursued.

so how to get a reviewer?

johba37 avatar Oct 11 '25 19:10 johba37

@mamoodi Can you review this PR?

erkinalp avatar Oct 12 '25 05:10 erkinalp

@mamoodi Can you review this PR?

I can only properly review doc updates. But let me post this in Slack and see if I can get some eyes on this. Thanks!

mamoodi avatar Oct 13 '25 13:10 mamoodi

Hey @johba37! I've been testing this and it works good so far :) I noticed the frontend UI was missing, so I implemented it on top of your work:

  • Complete UI integration (token input, settings page, i18n translations)
  • Environment variable support (FORGEJO_TOKEN, FORGEJO_BASE_URL)
  • Protocol normalization fix to prevent double-protocol git URLs

Would you like me to:

  1. Send a PR to your fork?
  2. Share commits for cherry-picking?
  3. Open a separate PR?

Let me know how you'd like to collaborate!

w9n avatar Nov 01 '25 10:11 w9n

Hey @johba37! I've been testing this and it works good so far :) I noticed the frontend UI was missing, so I implemented it on top of your work:

* Complete UI integration (token input, settings page, i18n translations)

* Environment variable support (FORGEJO_TOKEN, FORGEJO_BASE_URL)

* Protocol normalization fix to prevent double-protocol git URLs

Would you like me to:

1. Send a PR to your fork?

2. Share commits for cherry-picking?

3. Open a separate PR?

Let me know how you'd like to collaborate!

oh, yes, let's collaborate. I'm still experimenting and trying to have it convert issues to PRs.

I guess a separate PR against this parent repo would be best, and then we try to land both of them.

johba37 avatar Nov 02 '25 12:11 johba37

Hey @johba37! I've been testing this and it works good so far :) I noticed the frontend UI was missing, so I implemented it on top of your work:

* Complete UI integration (token input, settings page, i18n translations)

* Environment variable support (FORGEJO_TOKEN, FORGEJO_BASE_URL)

* Protocol normalization fix to prevent double-protocol git URLs

Would you like me to:

1. Send a PR to your fork?

2. Share commits for cherry-picking?

3. Open a separate PR?

Let me know how you'd like to collaborate!

Hi @w9n thank you for making these fixes. I personally don't think that a separate PR to the parent repo is a good idea, because this PR seems unfinished without your fixes and I don't think the maintainers of OpenHands are willing to merge an unfinished PR.

MrGeorgen avatar Nov 19 '25 10:11 MrGeorgen

Hey @johba37! I've been testing this and it works good so far :) I noticed the frontend UI was missing, so I implemented it on top of your work:

* Complete UI integration (token input, settings page, i18n translations)

* Environment variable support (FORGEJO_TOKEN, FORGEJO_BASE_URL)

* Protocol normalization fix to prevent double-protocol git URLs

Would you like me to:

1. Send a PR to your fork?

2. Share commits for cherry-picking?

3. Open a separate PR?

Let me know how you'd like to collaborate!

@w9n could you please publish your commits somewhere? If you don't have the time to get your code merged, it would be ok. I could take care of it. I just don't want your commits to only stay on your maschine, because I'm really interested in a gitea integration.

MrGeorgen avatar Nov 24 '25 20:11 MrGeorgen

@openhands Read and understand the goal of this PR. Then merge main branch into this PR’s branch and fix merge conflicts.

Note that this PR’s branch is johba37:forgejo-integration-rebased, which is from a fork, so make sure you add the remote and use it correctly to work with the remote.

Note that one reason for the merge conflicts is simply that we added Azure devops meanwhile. Make sure you fix the conflicts to preserve both carefully, and adapt as necessary. There might be other reasons for some merge conflicts.

When you’re done, push to the fork branch to update this PR automatically. Make sure you see the readme and makefile, so you know how to fix lint, and precommit config file is not in root dir, find it and use it correctly.

Do not ask me anything, you should investigate and figure it out.

enyst avatar Dec 08 '25 16:12 enyst

I'm on it! enyst can track my progress at all-hands.dev

openhands-ai[bot] avatar Dec 08 '25 16:12 openhands-ai[bot]

Final summary of work

What I did

  • Set up remotes and branch

    • Added fork remote (github.com/johba37/OpenHands.git) and checked out forgejo-integration-rebased tracking the fork.
  • Merged upstream main and resolved conflicts

    • Carefully preserved both Azure DevOps (new on main) and Forgejo integration.
    • Resolved and reconciled logic across:
      • openhands/integrations/provider.py: provider domains and service_class_map include Forgejo and Azure DevOps.
      • openhands/integrations/service_types.py: ProviderType includes both FORGEJO and AZURE_DEVOPS.
      • openhands/integrations/utils.py: validate_provider_token tries GitHub, GitLab, Forgejo (based on base_domain), Bitbucket, then Azure DevOps; improved debug logging accordingly.
      • openhands/resolver/issue_handler_factory.py: supports Forgejo and Azure DevOps for both issues and PRs; Azure DevOps owner parsed as organization/project.
      • openhands/resolver/send_pull_request.py: unified docstring and default domains to include Forgejo and Azure DevOps; removed conflict markers; standardized on PR_SIGNATURE for PR bodies; preserved Azure DevOps owner parsing.
      • tests/unit/integrations/bitbucket/test_bitbucket.py: fixed expected PR body to use PR_SIGNATURE.
      • tests/unit/resolver/test_issue_handler_factory.py: parametrized to test Forgejo and Azure DevOps; ensured base_domain handling and Azure format.
  • Fixed typing/signature drift

    • openhands/integrations/forgejo/service/repos.py: aligned search_repositories signature with GitService (added app_mode), resolving mypy complaints.
  • Linting and type checks

    • Installed and ran backend pre-commit via dev_config/python/.pre-commit-config.yaml; ruff, ruff-format, mypy passed.
    • Note: VSCode/Node checks in the custom .openhands/pre-commit.sh were skipped in this environment; Python checks fully passed.
  • Push

    • Committed merge resolution and pushed to johba37:forgejo-integration-rebased, updating the PR.

Checklist against your instructions

  • [x] Read and understood the PR’s goal (Forgejo integration parity) and current context.
  • [x] Merged main into the PR branch and fixed conflicts.
  • [x] Preserved both Azure DevOps (new) and Forgejo changes, adapting code where necessary.
  • [x] Used the correct pre-commit config (dev_config/python/.pre-commit-config.yaml); backend hooks pass.
  • [x] Pushed updates to the fork branch to update the PR automatically.

Conciseness and scope

  • Changes were limited to conflict resolution and necessary adaptations for both providers plus unit test adjustments. No extraneous modifications beyond what was required to reconcile Forgejo with newly added Azure DevOps.

Status

  • Branch forgejo-integration-rebased on johba37/OpenHands has been updated and pushed. The PR should now reflect the merged main with conflicts resolved.

View full conversation

openhands-ai[bot] avatar Dec 08 '25 16:12 openhands-ai[bot]

@neubig re. https://openhands-ai.slack.com/archives/C086ARSNMGA/p1765201394700469?thread_ts=1765199062.439909&cid=C086ARSNMGA

erkinalp avatar Dec 09 '25 05:12 erkinalp