Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
cc712022
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cc712022
编写于
2月 20, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: clone command
上级
192db5f7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
54 addition
and
4 deletion
+54
-4
extensions/git/package.json
extensions/git/package.json
+5
-0
extensions/git/package.nls.json
extensions/git/package.nls.json
+2
-1
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+32
-0
extensions/git/src/git.ts
extensions/git/src/git.ts
+8
-0
extensions/git/src/model.ts
extensions/git/src/model.ts
+7
-3
未找到文件。
extensions/git/package.json
浏览文件 @
cc712022
...
...
@@ -21,6 +21,11 @@
},
"contributes"
:
{
"commands"
:
[
{
"command"
:
"git.clone"
,
"title"
:
"%command.clone%"
,
"category"
:
"Git"
},
{
"command"
:
"git.init"
,
"title"
:
"%command.init%"
,
...
...
extensions/git/package.nls.json
浏览文件 @
cc712022
{
"command.init"
:
"Initialize Git Repository"
,
"command.clone"
:
"Clone"
,
"command.init"
:
"Initialize Repository"
,
"command.refresh"
:
"Refresh"
,
"command.openChange"
:
"Open Change"
,
"command.openFile"
:
"Open File"
,
...
...
extensions/git/src/commands.ts
浏览文件 @
cc712022
...
...
@@ -10,6 +10,7 @@ import { Ref, RefType } from './git';
import
{
Model
,
Resource
,
Status
,
CommitOptions
}
from
'
./model
'
;
import
*
as
staging
from
'
./staging
'
;
import
*
as
path
from
'
path
'
;
import
*
as
os
from
'
os
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -184,6 +185,37 @@ export class CommandCenter {
return
''
;
}
@
command
(
'
git.clone
'
)
async
clone
():
Promise
<
void
>
{
const
url
=
await
window
.
showInputBox
({
prompt
:
localize
(
'
repourl
'
,
"
Repository URL
"
)
});
if
(
!
url
)
{
return
;
}
const
parentPath
=
await
window
.
showInputBox
({
prompt
:
localize
(
'
parent
'
,
"
Parent Directory
"
),
value
:
os
.
homedir
()
});
if
(
!
parentPath
)
{
return
;
}
const
clonePromise
=
this
.
model
.
git
.
clone
(
url
,
parentPath
);
window
.
setStatusBarMessage
(
localize
(
'
cloning
'
,
"
Cloning git repository...
"
),
clonePromise
);
const
repositoryPath
=
await
clonePromise
;
const
open
=
localize
(
'
openrepo
'
,
"
Open Repository
"
);
const
result
=
await
window
.
showInformationMessage
(
localize
(
'
proposeopen
'
,
"
Would you like to open the cloned repository?
"
),
open
);
if
(
result
===
open
)
{
commands
.
executeCommand
(
'
vscode.openFolder
'
,
Uri
.
file
(
repositoryPath
));
}
}
@
command
(
'
git.init
'
)
async
init
():
Promise
<
void
>
{
await
this
.
model
.
init
();
...
...
extensions/git/src/git.ts
浏览文件 @
cc712022
...
...
@@ -289,6 +289,14 @@ export class Git {
return
new
Repository
(
this
,
repository
,
env
);
}
async
clone
(
url
:
string
,
parentPath
:
string
):
Promise
<
string
>
{
const
folderName
=
url
.
replace
(
/^.*
\/
/
,
''
).
replace
(
/
\.
git$/
,
''
)
||
'
repository
'
;
const
folderPath
=
path
.
join
(
parentPath
,
folderName
);
await
this
.
exec
(
parentPath
,
[
'
clone
'
,
url
,
folderPath
]);
return
folderPath
;
}
async
getRepositoryRoot
(
path
:
string
):
Promise
<
string
>
{
const
result
=
await
this
.
exec
(
path
,
[
'
rev-parse
'
,
'
--show-toplevel
'
]);
return
result
.
stdout
.
trim
();
...
...
extensions/git/src/model.ts
浏览文件 @
cc712022
...
...
@@ -249,6 +249,10 @@ export class Model implements Disposable {
return
anyEvent
(
this
.
onRunOperation
as
Event
<
any
>
,
this
.
onDidRunOperation
as
Event
<
any
>
);
}
get
git
():
Git
{
return
this
.
_git
;
}
private
_mergeGroup
=
new
MergeGroup
([]);
get
mergeGroup
():
MergeGroup
{
return
this
.
_mergeGroup
;
}
...
...
@@ -314,7 +318,7 @@ export class Model implements Disposable {
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
git
:
Git
,
private
_
git
:
Git
,
private
rootPath
:
string
,
private
askpass
:
Askpass
)
{
...
...
@@ -497,9 +501,9 @@ export class Model implements Disposable {
this
.
repositoryDisposable
.
dispose
();
const
disposables
:
Disposable
[]
=
[];
const
repositoryRoot
=
await
this
.
git
.
getRepositoryRoot
(
this
.
rootPath
);
const
repositoryRoot
=
await
this
.
_
git
.
getRepositoryRoot
(
this
.
rootPath
);
const
askpassEnv
=
await
this
.
askpass
.
getEnv
();
this
.
repository
=
this
.
git
.
open
(
repositoryRoot
,
askpassEnv
);
this
.
repository
=
this
.
_
git
.
open
(
repositoryRoot
,
askpassEnv
);
const
dotGitPath
=
path
.
join
(
repositoryRoot
,
'
.git
'
);
const
{
event
:
onRawGitChange
,
disposable
:
watcher
}
=
watch
(
dotGitPath
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录