Skip to content

fix(gitlab): open the New-MR page on the fork project for fork-pushed branches - #7654

Merged
nwparker merged 1 commit into
stablyai:mainfrom
xianjianlf2:fix/gitlab-new-mr-fork-head-repo
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
xianjianlf2:fix/gitlab-new-mr-fork-head-repo

Conversation

@xianjianlf2

@xianjianlf2 xianjianlf2 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes GitLab "Create MR in browser" landing on a broken New-MR page (404) when the branch was pushed to a fork.

ELI5

When you asked Orca to open a merge request for a branch you pushed to your own fork, it sent you to the wrong project's page — one that couldn't see your branch. Now it opens the right page where your branch actually lives.

Root cause & fix

buildSourceControlManualReviewUrl computes a headRepo to support forks, but the GitLab branch of the switch ignored it and always built /-/merge_requests/new on the base repo. For a fork-pushed branch, the source_branch only exists on the fork project, so the base project's New-MR page 404s. The fix builds the GitLab URL on headRepo.webBaseUrl instead of baseRepo.webBaseUrl, matching what the GitHub branch already does. For non-fork remotes headRepo === baseRepo, so it's a no-op.

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.

  • Test file: src/renderer/src/components/right-sidebar/source-control-manual-review-url.test.ts
  • Pass on branch: 17 passed (17), 1 file passed.
  • Reverting the fix to origin/main fails the new fork case (1 failed | 16 passed):
× opens the GitLab New-MR page on the fork project when the branch was pushed to a fork
  Expected: https://gitlab.company.test/contributor/orca/-/merge_requests/new?...
  Received: https://gitlab.company.test/group/sub/orca/-/merge_requests/new?...
  • Rebase clean (base 7ab601487c, head 506840bba9).
  • Lint clean: oxlint on the fixed file reports no findings.

Trade-offs

None — pure fix.

Regression risk

Zero-regression: only the GitLab branch of the switch changes, and headRepo === baseRepo for non-fork remotes, so existing self-hosted/origin GitLab links are byte-identical (covered by the passing self-hosted GitLab test). No other providers (GitHub/Bitbucket) are touched.

Credit to original author @xianjianlf2 (Mark Xian). Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change modifies the GitLab branch of buildSourceControlManualReviewUrl so the generated "New merge request" URL is built from the head repository's web base URL rather than the base repository's, addressing a scenario where the source branch resides in a forked project. Inline comments were updated to explain the rationale. A new test case was added verifying correct URL generation when the branch was pushed to a fork.

Changes

File Summary
source-control-manual-review-url.ts Changed GitLab new merge request URL base from baseRepo.webBaseUrl to headRepo.webBaseUrl; updated comments
source-control-manual-review-url.test.ts Added test verifying correct GitLab MR URL for fork push scenario

Sequence Diagram(s)

Not applicable; change is a single conditional URL construction adjustment without multi-component interaction.

Related issues: None specified.

Related PRs: None specified.

Suggested labels: bug, gitlab, tests

Suggested reviewers: None specified.

Poem: A rabbit hopped through forked terrain,
Found the MR link led to no gain.
"Base repo's wrong!" it cheerfully cried,
"Head repo's URL is the branch's true guide."
Now merge requests find their way again.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, root cause, evidence, and risk, but it omits required template sections like Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or 'No visual change', the testing checklist, AI review report, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly states the GitLab fork-project MR URL fix and matches the main change.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6debc59a-67d7-42fc-a629-ac8d45199311

📥 Commits

Reviewing files that changed from the base of the PR and between f057c9d and 506840bba97fc829ddc1aa5804b318fb4ba85fa1.

📒 Files selected for processing (2)
  • src/renderer/src/components/right-sidebar/source-control-manual-review-url.test.ts
  • src/renderer/src/components/right-sidebar/source-control-manual-review-url.ts

… branches

buildSourceControlManualReviewUrl computes headRepo precisely to support
forks — the GitHub branch qualifies the head via githubHeadRef — but the
GitLab branch discarded it and always built /-/merge_requests/new on the base
repo. When the branch was pushed to a fork, GitLab can't see source_branch on
the base project, so the user landed on a broken New-MR page.

Build the URL on headRepo.webBaseUrl (where the branch actually lives); GitLab
defaults the target to the fork's upstream. headRepo === baseRepo for the
non-fork case, so it's a no-op there.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@nwparker
nwparker force-pushed the fix/gitlab-new-mr-fork-head-repo branch from 506840b to 638d0ef Compare July 23, 2026 11:48
@nwparker
nwparker merged commit afa549f into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @xianjianlf2 — open the New-MR page on the fork project for fork-pushed branches. Reviewed, rebased on latest main, and merged. Really appreciate the contribution! 🙏

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

3 participants