瀏覽代碼

Fixes #2553 allows remote formats we can parse

main
Eric Amodio 1 年之前
父節點
當前提交
056512bfc3
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. +2
    -1
      src/commands/quickCommand.steps.ts
  2. +2
    -2
      src/git/parsers/remoteParser.ts

+ 2
- 1
src/commands/quickCommand.steps.ts 查看文件

@ -37,6 +37,7 @@ import type { GitStatus } from '../git/models/status';
import type { GitTag, TagSortOptions } from '../git/models/tag';
import { sortTags } from '../git/models/tag';
import type { GitWorktree } from '../git/models/worktree';
import { remoteUrlRegex } from '../git/parsers/remoteParser';
import {
CommitApplyFileChangesCommandQuickPickItem,
CommitBrowseRepositoryFromHereCommandQuickPickItem,
@ -606,7 +607,7 @@ export async function* inputRemoteUrlStep<
value = value.trim();
if (value.length === 0) return [false, 'Please enter a valid remote URL'];
const valid = /^(https?|git|ssh|rsync):\/\//.test(value);
const valid = remoteUrlRegex.test(value);
return [valid, valid ? undefined : `'${value}' isn't a valid remote URL`];
},
});

+ 2
- 2
src/git/parsers/remoteParser.ts 查看文件

@ -109,11 +109,11 @@ user:password@host.xz:project.git
user:password@host.xz:/path/to/repo.git
user:password@host.xz:/path/to/repo.git/
*/
const urlRegex =
export const remoteUrlRegex =
/^(?:(git:\/\/)(.*?)\/|(https?:\/\/)(?:.*?@)?(.*?)\/|git@(.*):|(ssh:\/\/)(?:.*@)?(.*?)(?::.*?)?(?:\/|(?=~))|(?:.*?@)(.*?):)(.*)$/;
export function parseGitRemoteUrl(url: string): [scheme: string, domain: string, path: string] {
const match = urlRegex.exec(url);
const match = remoteUrlRegex.exec(url);
if (match == null) return [emptyStr, emptyStr, url];
return [

Loading…
取消
儲存