Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0f190483
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0f190483
编写于
10月 22, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💄
上级
990c0284
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
22 deletion
+23
-22
extensions/git/package.json
extensions/git/package.json
+3
-8
extensions/git/package.nls.json
extensions/git/package.nls.json
+1
-1
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+6
-6
extensions/git/src/git.ts
extensions/git/src/git.ts
+13
-7
未找到文件。
extensions/git/package.json
浏览文件 @
0f190483
...
...
@@ -39,8 +39,8 @@
"category"
:
"Git"
},
{
"command"
:
"git.cloneRecursive
ly
"
,
"title"
:
"%command.cloneRecursive
ly
%"
,
"command"
:
"git.cloneRecursive"
,
"title"
:
"%command.cloneRecursive%"
,
"category"
:
"Git"
},
{
...
...
@@ -501,7 +501,7 @@
"when"
:
"config.git.enabled && !git.missing"
},
{
"command"
:
"git.cloneRecursive
ly
"
,
"command"
:
"git.cloneRecursive"
,
"when"
:
"config.git.enabled && !git.missing"
},
{
...
...
@@ -894,11 +894,6 @@
"command"
:
"git.showOutput"
,
"group"
:
"3_footer"
,
"when"
:
"scmProvider == git"
},
{
"command"
:
"git.cloneRecursively"
,
"group"
:
"3_footer"
,
"when"
:
"scmProvider == git"
}
],
"scm/sourceControl"
:
[
...
...
extensions/git/package.nls.json
浏览文件 @
0f190483
...
...
@@ -3,7 +3,7 @@
"description"
:
"Git SCM Integration"
,
"command.setLogLevel"
:
"Set Log Level..."
,
"command.clone"
:
"Clone"
,
"command.cloneRecursive
ly"
:
"Clone Recursively
"
,
"command.cloneRecursive
"
:
"Clone (Recursive)
"
,
"command.init"
:
"Initialize Repository"
,
"command.openRepository"
:
"Open Repository"
,
"command.close"
:
"Close Repository"
,
...
...
extensions/git/src/commands.ts
浏览文件 @
0f190483
...
...
@@ -458,7 +458,7 @@ export class CommandCenter {
}
}
async
cloneRepository
(
url
?:
string
,
parentPath
?:
string
,
shouldRecurse
?:
boolean
):
Promise
<
void
>
{
async
cloneRepository
(
url
?:
string
,
parentPath
?:
string
,
options
:
{
recursive
?:
boolean
}
=
{}
):
Promise
<
void
>
{
if
(
!
url
||
typeof
url
!==
'
string
'
)
{
url
=
await
pickRemoteSource
(
this
.
model
,
{
providerLabel
:
provider
=>
localize
(
'
clonefrom
'
,
"
Clone from {0}
"
,
provider
.
name
),
...
...
@@ -514,7 +514,7 @@ export class CommandCenter {
const
repositoryPath
=
await
window
.
withProgress
(
opts
,
(
progress
,
token
)
=>
this
.
git
.
clone
(
url
!
,
parentPath
!
,
progress
,
token
,
shouldRecurse
)
(
progress
,
token
)
=>
this
.
git
.
clone
(
url
!
,
{
parentPath
:
parentPath
!
,
progress
,
recursive
:
options
.
recursive
},
token
)
);
let
message
=
localize
(
'
proposeopen
'
,
"
Would you like to open the cloned repository?
"
);
...
...
@@ -573,12 +573,12 @@ export class CommandCenter {
@
command
(
'
git.clone
'
)
async
clone
(
url
?:
string
,
parentPath
?:
string
):
Promise
<
void
>
{
this
.
cloneRepository
(
url
,
parentPath
,
false
);
this
.
cloneRepository
(
url
,
parentPath
);
}
@
command
(
'
git.cloneRecursive
ly
'
)
async
cloneRecursive
ly
(
url
?:
string
,
parentPath
?:
string
):
Promise
<
void
>
{
this
.
cloneRepository
(
url
,
parentPath
,
true
);
@
command
(
'
git.cloneRecursive
'
)
async
cloneRecursive
(
url
?:
string
,
parentPath
?:
string
):
Promise
<
void
>
{
this
.
cloneRepository
(
url
,
parentPath
,
{
recursive
:
true
}
);
}
@
command
(
'
git.init
'
)
...
...
extensions/git/src/git.ts
浏览文件 @
0f190483
...
...
@@ -351,6 +351,12 @@ function sanitizePath(path: string): string {
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%ct%n%P%n%B';
export interface ICloneOptions {
readonly parentPath: string;
readonly progress: Progress<{ increment: number }>;
readonly recursive?: boolean;
}
export class Git {
readonly path: string;
...
...
@@ -373,18 +379,18 @@ export class Git {
return;
}
async clone(url: string,
parentPath: string, progress: Progress<{ increment: number }>, cancellationToken?: CancellationToken, shouldRecurse?: boolea
n): Promise<string> {
async clone(url: string,
options: ICloneOptions, cancellationToken?: CancellationToke
n): Promise<string> {
let baseFolderName = decodeURI(url).replace(/[\/]+$/, '').replace(/^.*[\/\\]/, '').replace(/\.git$/, '') || 'repository';
let folderName = baseFolderName;
let folderPath = path.join(parentPath, folderName);
let folderPath = path.join(
options.
parentPath, folderName);
let count = 1;
while (count < 20 && await new Promise(c => exists(folderPath, c))) {
folderName = `
$
{
baseFolderName
}
-
$
{
count
++
}
`;
folderPath = path.join(parentPath, folderName);
folderPath = path.join(
options.
parentPath, folderName);
}
await mkdirp(parentPath);
await mkdirp(
options.
parentPath);
const onSpawn = (child: cp.ChildProcess) => {
const decoder = new StringDecoder('utf8');
...
...
@@ -408,7 +414,7 @@ export class Git {
}
if (totalProgress !== previousProgress) {
progress.report({ increment: totalProgress - previousProgress });
options.
progress.report({ increment: totalProgress - previousProgress });
previousProgress = totalProgress;
}
});
...
...
@@ -416,10 +422,10 @@ export class Git {
try {
let command = ['clone', url.includes(' ') ? encodeURI(url) : url, folderPath, '--progress'];
if (
shouldRecurs
e) {
if (
options.recursiv
e) {
command.push('--recursive');
}
await this.exec(parentPath, command, { cancellationToken, onSpawn });
await this.exec(
options.
parentPath, command, { cancellationToken, onSpawn });
} catch (err) {
if (err.stderr) {
err.stderr = err.stderr.replace(/^Cloning.+$/m, '').trim();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录