fix(server): self-hosted GitLab projects resolve bare pull request numbers #15395
MergedTonybynMp4(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/15395/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/sourceControl/refineRepositoryIdentity.ts lines 28 to 28OutdatedResolvedby TonybynMp4(GitHub profile, opens in a new tab)@@ -0,0 +8,21 @@8+const UNKNOWN_PROVIDER = { kind: "unknown", name: "Unknown", baseUrl: "" } as const;9+10+/**11+ * Settles the provider of an identity whose remote host does not name one, by asking the CLIs12+ * signed in on this machine. A self-hosted GitLab or Forgejo is otherwise `unknown`, and13+ * clients cannot build its change request URLs, so a bare `#123` has nowhere to point.14+ */15+export const refineRepositoryIdentity = (16+ registry: SourceControlProviderRegistry.SourceControlProviderRegistry["Service"],17+) =>18+ Effect.fn("refineRepositoryIdentity")(function* (identity: RepositoryIdentity) {19+ const remote = ForgejoCli.parseForgejoRemote(identity.locator.remoteUrl);20+ const unknown = identity.provider === undefined || identity.provider === "unknown";21+ if (!remote || !identity.rootPath || (!unknown && identity.provider !== "forgejo"))22+ return identity;23+ // `glab` matches its logins against the provider name, which is the host for an unknown one.24+ const detected = detectSourceControlProviderFromRemoteUrl(identity.locator.remoteUrl);25+ const handle = yield* registry.resolveHandle({26+ cwd: identity.rootPath,27+ context: {28+ provider: detected?.kind === "unknown" ? detected : UNKNOWN_PROVIDER,
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge added labelsmacroscope-review
- packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts line 106OutdatedResolvedby TonybynMp4(GitHub profile, opens in a new tab)@@ -97,3 +98,9 @@9798 } as const;9899 }99100101+/** The provider an unknown remote reads as, named by its host, which is what `glab` logins match. */102+function unknownRemoteProvider(remoteUrl: string) {103+ const detected = detectSourceControlProviderFromRemoteUrl(remoteUrl);104+ if (detected) return detected.kind === "unknown" ? detected : null;105+ // An SCP remote with no user (`host:group/project.git`) is not detected.106+ const host = /^([^@:/]+):[^/]/.exec(remoteUrl.trim())?.[1]?.toLowerCase();
juliusmarminge assignedjuliusmarminge
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this221831f
juliusmarminge closed this
Sign in to join this conversation.


Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
📝 Walkthrough
The GitLab provider now refines eligible unknown repository identities by resolving the remote host. It sets the provider to GitLab when that host resolves to GitLab. Remote URL normalization now handles additional SCP-style forms.
Changes: Repository identity refinement
packages/shared/src/git.ts,packages/shared/src/git.test.tspackages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts,packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.tsPriority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
juliusmarmingeMerge Risk: 🔵 Low · up to
99ef2A narrow Windows configuration can mistake a local path for a GitLab remote and produce incorrect merge-request links. The issue is bounded, but should be corrected or accepted before relying on that workflow.
Architecture risk: 🔵 Low · up to
99ef2The change affects 2 systems.
Changed systems:
packages/shared,packages/source-control-gitlabArchitecture concerns No architecture-level concerns identified.
Review details
Systems and components
Before / after behavior
"unknown"; it resolves the inferred provider with the repository context and sets the identity provider to"gitlab"only if resolution identifies GitLab. Otherwise, it preserves the identity.refineRepositoryIdentityon the GitLab provider implementation.Pre-merge checks:
4
#15390] requires bare merge-request numbers to resolve for a self-hosted GitLab host whenglabis authenticated to that host.refineRepositoryIdentityderives the remote host, resolves that…#15390]. The host-basednormalizeGitRemoteUrlkeys and related tests enable the required remote forms. The GitLab refinement and discovery changes implement the required p…Full details: Linked Issues check
Explanation
Issue [
#15390] requires bare merge-request numbers to resolve for a self-hosted GitLab host whenglabis authenticated to that host.refineRepositoryIdentityderives the remote host, resolves that host through GitLab discovery, and sets the identity provider togitlabonly after authenticated matching. The existing GitLab URL behavior then supplies/-/merge_requests/N. The implementation handles HTTPS and user-less SCP remotes, preserves known providers, and tests authenticated, unmatched, and GitHub cases.Full details: Out of Scope Changes check
Explanation
The changes support issue [
#15390]. The host-basednormalizeGitRemoteUrlkeys and related tests enable the required remote forms. The GitLab refinement and discovery changes implement the required provider resolution. The changes preserve unknown-host and known-provider behavior. GitHub Enterprise support remains explicitly outside this change.Full details: Description check
Explanation
The description clearly explains the self-hosted GitLab problem, the implementation, scope limits, linked issue and approval context, verification results, limitations, and agent usage. It does not use the template's section headings, but it includes the required information and is sufficiently complete.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.