From c3a3a6e2f0320335c1a065fe0fe8060ad866d9b6 Mon Sep 17 00:00:00 2001 From: Matt Evans <1388610+matthewevans@users.noreply.github.com> Date: Mon, 28 Apr 2025 15:28:31 -0700 Subject: [PATCH] fix(github): Include owner in head parameter for PRs from forks --- .../desktop/src/components/ReviewCreation.svelte | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/components/ReviewCreation.svelte b/apps/desktop/src/components/ReviewCreation.svelte index 787b990f50..bb14247e36 100644 --- a/apps/desktop/src/components/ReviewCreation.svelte +++ b/apps/desktop/src/components/ReviewCreation.svelte @@ -27,7 +27,9 @@ import { StackPublishingService } from '$lib/history/stackPublishingService'; import { showError, showToast } from '$lib/notifications/toasts'; import { ProjectsService } from '$lib/project/projectsService'; + import { RemotesService } from '$lib/remotes/remotesService'; import { StackService } from '$lib/stacks/stackService.svelte'; + import { parseRemoteUrl } from '$lib/url/gitUrl'; import { UserService } from '$lib/user/userService'; import { getBranchNameFromRef } from '$lib/utils/branch'; import { sleep } from '$lib/utils/sleep'; @@ -63,6 +65,7 @@ const userService = getContext(UserService); const templateService = getContext(TemplateService); const aiService = getContext(AIService); + const remotesService = getContext(RemotesService); const user = userService.user; const project = projectsService.getProjectStore(projectId); @@ -276,12 +279,23 @@ base = branchParent.name; } + const pushRemoteName = baseBranch.actualPushRemoteName(); + const allRemotes = await remotesService.remotes(projectId); + const pushRemote = allRemotes.find((r) => r.name === pushRemoteName); + const pushRemoteUrl = pushRemote?.url; + + const repoInfo = parseRemoteUrl(pushRemoteUrl); + + const upstreamName = repoInfo?.owner + ? `${repoInfo.owner}:${params.upstreamBranchName}` + : params.upstreamBranchName; + const pr = await prService.createPr({ title: params.title, body: params.body, draft: params.draft, baseBranchName: base, - upstreamName: params.upstreamBranchName + upstreamName }); // Store the new pull request number with the branch data.