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

This commit is contained in:
JackatDJL authored and GitHub committed 2026-08-15 12:26:45 +00:00
1 parent dc0ff8f13e
commit 7ce4194707
6 files changed
+72 -16

No files matched your search

@@ -14,7 +14,10 @@ import {
} from "@t3tools/contracts";
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
import { sanitizeBranchFragment } from "@t3tools/shared/git";
import { detectSourceControlProviderFromRemoteUrl } from "@t3tools/shared/sourceControl";
import {
detectSourceControlProviderFromRemoteUrl,
isSshRemoteUrl,
} from "@t3tools/shared/sourceControl";
import {
BitbucketPullRequestListSchema,
@@ -448,9 +451,9 @@ function requireRepositoryLocator(
function parseBitbucketRemoteUrl(remoteUrl: string): BitbucketRepositoryLocator | null {
const trimmed = remoteUrl.trim();
if (trimmed.startsWith("git@")) {
const pathStart = trimmed.indexOf(":");
return pathStart < 0 ? null : parseBitbucketRepositorySlug(trimmed.slice(pathStart + 1));
const scpMatch = /^[a-zA-Z0-9._-]+@[^:/]+:(.+)$/.exec(trimmed);
if (scpMatch?.[1]) {
return parseBitbucketRepositorySlug(scpMatch[1]);
}
try {
@@ -494,8 +497,8 @@ function defaultChangeRequestTargetBranch(input: {
}
function shouldPreferSshRemote(originRemoteUrl: string | null): boolean {
const trimmed = originRemoteUrl?.trim() ?? "";
return trimmed.startsWith("git@") || trimmed.startsWith("ssh://");
if (!originRemoteUrl) return false;
return isSshRemoteUrl(originRemoteUrl);
}
function selectCloneUrl(input: {