From 915290734ab42d6a8c11d0f2deb4f566748450eb Mon Sep 17 00:00:00 2001 From: Leon Lux Date: Fri, 30 Oct 2026 09:59:44 +0000 Subject: [PATCH] Support creating Pull Requests on Codeberg via Zed UI (#66182) ## Summary Currently, trying to create a pr via zeds ui fails with the error: ``` Unable to construct pull request URL ``` This PR fixes this by providing an implementation of `GitHostingProvider::build_create_pull_request_url` to the Forgejo git hosting provider. ## Testing Tested by adding a unit test that verifies the generated pull request url matches the expected structure. Verified that it works end-to-end by creating a PR on codeberg via a build of this pr. ## Self-review - [X] I've reviewed my diff for quality, security, reliability, and performance. - [ ] ~~UI changes follow the checklist~~ (N/A, no UI changes) - [X] Tests cover the new or changed behavior. Release Notes: - Fixed creating pull requests from Zed for Forgejo remotes (including Codeberg). --- .../src/providers/forgejo.rs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/crates/git_hosting_providers/src/providers/forgejo.rs b/crates/git_hosting_providers/src/providers/forgejo.rs index d31288655e4..c1185795405 100644 --- a/crates/git_hosting_providers/src/providers/forgejo.rs +++ b/crates/git_hosting_providers/src/providers/forgejo.rs @@ -228,6 +228,21 @@ impl GitHostingProvider for Forgejo { permalink } + fn build_create_pull_request_url( + &self, + remote: &ParsedGitRemote, + source_branch: &str, + ) -> Option { + let ParsedGitRemote { owner, repo } = remote; + let mut url = self.base_url(); + url.path_segments_mut() + .ok()? + .pop_if_empty() + .extend([owner.as_ref(), repo.as_ref(), "compare"]) + .extend(source_branch.split('/')); + Some(url) + } + async fn commit_author_avatar_url( &self, repo_owner: &str, @@ -319,6 +334,22 @@ mod tests { ); } + #[test] + fn test_build_codeberg_create_pull_request_url() { + let remote = ParsedGitRemote { + owner: "zed-industries".into(), + repo: "zed".into(), + }; + let url = Forgejo::public_instance() + .build_create_pull_request_url(&remote, "feature/new-feature") + .expect("should be able to build pull request url"); + + assert_eq!( + url.as_str(), + "https://codeberg.org/zed-industries/zed/compare/feature/new-feature" + ); + } + #[test] fn test_parse_remote_url_given_self_hosted_https_url() { let remote_url = "https://forgejo.my-enterprise.com/zed-industries/zed.git";