Skip to content

fix: detect SSH remotes with non-git user prefixes (e.g. gitlab@)#3649

Open
JackatDJL wants to merge 2 commits into
pingdotgg:mainfrom
JackatDJL:fix/ssh-remote-non-git-user
Open

fix: detect SSH remotes with non-git user prefixes (e.g. gitlab@)#3649
JackatDJL wants to merge 2 commits into
pingdotgg:mainfrom
JackatDJL:fix/ssh-remote-non-git-user

Conversation

@JackatDJL

@JackatDJL JackatDJL commented Jul 2, 2026

Copy link
Copy Markdown

What changed

parseRemoteHost only handled the git@ prefix when parsing SCP-like SSH remote URLs. Enterprise GitLab instances commonly use gitlab@ as the SSH user (GitLab's default), so remotes like gitlab@gitlab.example.com:group/project.git were not parsed — parseRemoteHost returned null, the provider stayed unknown, and every PR/MR operation failed with:

Source control provider unknown failed in listChangeRequests: No unknown source control provider is registered.

Replaced the startsWith("git@") check with a regex (/^[a-zA-Z0-9._-]+@([^:/]+)[:/]/) that matches any SCP-like SSH syntax, covering git@, gitlab@, deploy@, and any other SSH user prefix.

Extracted a shared isSshRemoteUrl helper in packages/shared/src/sourceControl.ts and used it to fix the same startsWith("git@") pattern in:

  • apps/server/src/git/GitManager.tsshouldPreferSshRemote (clone URL selection)
  • apps/server/src/sourceControl/BitbucketApi.tsparseBitbucketRemoteUrl and shouldPreferSshRemote

Why

SCP-like SSH syntax (user@host:path) is standard git remote format. The SSH user is not always git — GitLab uses gitlab@, Bitbucket Server uses git@ or custom users, and enterprise deployments may use any username. Hardcoding git@ breaks provider detection for all of these.

Tests

Added test cases for:

  • detectSourceControlProviderFromRemoteUrl with gitlab@ and deploy@ SSH users
  • isSshRemoteUrl for SCP-like, ssh://, HTTPS, and local paths

Existing tests and typecheck pass (verified with tsgo per-package; vp test runner has a native binding issue on this platform).

Closes #3648


Note

Medium Risk
Touches shared remote parsing used for provider detection, clone URL choice, and Bitbucket slug extraction; wrong regex behavior could misclassify remotes, though scope is narrow and well covered by new tests.

Overview
Fixes provider detection and clone URL selection for SCP-style SSH remotes whose SSH user is not git (e.g. GitLab’s gitlab@), which previously left the provider as unknown and broke PR/MR flows.

Adds shared isSshRemoteUrl and a SCP_SSH_REMOTE_PATTERN in sourceControl.ts, updates parseRemoteHost to extract the host from any user@host:path form, and wires GitManager / BitbucketApi SSH preference and Bitbucket URL parsing through that helper instead of startsWith("git@"). normalizeGitRemoteUrl in git.ts uses the same broader SCP regex so non-git users normalize consistently.

Tests cover gitlab@ / deploy@ detection, isSshRemoteUrl edge cases, and SCP normalization. SCP-like strings without a colon are no longer treated as SSH and may not yield a host from SCP parsing.

Reviewed by Cursor Bugbot for commit 8242b99. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix SSH remote detection to support non-git username prefixes (e.g. gitlab@, deploy@)

  • Introduces isSshRemoteUrl and SCP_SSH_REMOTE_PATTERN in sourceControl.ts to detect SCP-like SSH remotes with any valid username, not just git@.
  • Updates normalizeGitRemoteUrl in git.ts and parseRemoteHost in sourceControl.ts to use the generalized pattern for host/path extraction.
  • Replaces manual git@/ssh:// string checks in GitManager.shouldPreferSshRemote and BitbucketApi with calls to the shared isSshRemoteUrl helper.
  • Fixes BitbucketApi.parseBitbucketRemoteUrl to correctly parse SCP-like remotes that use non-git SSH users (e.g. deploy@bitbucket.org:workspace/repo.git).

Macroscope summarized 8242b99.

Copilot AI review requested due to automatic review settings July 2, 2026 11:52
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 03b241a5-9501-43e8-81a9-d3e78daa6622

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 2, 2026

Copilot AI 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.

Pull request overview

This PR fixes source control provider detection and SSH-vs-HTTPS clone URL preference for SCP-like SSH remotes that use non-git usernames (e.g. gitlab@host:group/project.git), which is common on enterprise/self-hosted GitLab and other deployments.

Changes:

  • Generalized SCP-like SSH remote parsing in parseRemoteHost to support any SSH user prefix (not just git@).
  • Added a shared isSshRemoteUrl helper and reused it for SSH remote preference checks in server code.
  • Added test coverage for provider detection with non-git SSH usernames and for isSshRemoteUrl.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/shared/src/sourceControl.ts Generalizes SCP-like SSH parsing and adds isSshRemoteUrl helper used by server code.
packages/shared/src/sourceControl.test.ts Adds tests for provider detection with gitlab@/deploy@ and for SSH URL detection.
apps/server/src/sourceControl/BitbucketApi.ts Uses shared SSH detection for clone URL selection; broadens SCP-like remote parsing for Bitbucket slug extraction.
apps/server/src/git/GitManager.ts Uses shared SSH detection for clone URL selection logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/shared/src/sourceControl.ts Outdated
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 2, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Bug fix that expands SSH remote URL detection to handle non-standard SSH user prefixes (gitlab@, deploy@) in addition to git@. Changes are limited to regex pattern updates with comprehensive test coverage, posing minimal runtime risk.

You can customize Macroscope's approvability policy. Learn more.

@JackatDJL JackatDJL force-pushed the fix/ssh-remote-non-git-user branch from 08aceb1 to e32032c Compare July 2, 2026 11:59
@macroscopeapp macroscopeapp Bot dismissed their stale review July 2, 2026 11:59

Dismissing prior approval to re-evaluate e32032c

Comment thread packages/shared/src/sourceControl.ts Outdated
parseRemoteHost only handled the git@ prefix when parsing SCP-like SSH
remote URLs. Enterprise GitLab instances commonly use gitlab@ as the SSH
user, causing host detection to fail and the provider to stay unknown.

Replace startsWith("git@") with a regex matching any SCP-like SSH syntax
(user@host:path). Extract a shared isSshRemoteUrl helper and use it in
GitManager and BitbucketApi to fix the same pattern there.

Closes pingdotgg#3648
@JackatDJL JackatDJL force-pushed the fix/ssh-remote-non-git-user branch from e32032c to 536dc17 Compare July 2, 2026 12:08

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 536dc17. Configure here.

Comment thread packages/shared/src/sourceControl.ts
normalizeGitRemoteUrl in packages/shared/src/git.ts still used the old
git@ prefix and [:/] separator, inconsistent with the fixed parseRemoteHost
which now requires : and accepts any SSH user prefix.

- Require : as SCP separator (git@host:path, not git@host/path)
- Generalize git@ to [a-zA-Z0-9._-]+@ for gitlab@, deploy@, etc.

Addresses Cursor Bugbot review comment on PR pingdotgg#3649.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enterprise GitLab remotes with non-git SSH user (e.g. gitlab@) not detected — provider stays unknown

2 participants