Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b9eb8bae
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,发现更多精彩内容 >>
提交
b9eb8bae
编写于
8月 15, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: add across multiple repositories
上级
b8b36a0f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
13 deletion
+50
-13
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+39
-12
extensions/git/src/modelRegistry.ts
extensions/git/src/modelRegistry.ts
+11
-1
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
b9eb8bae
...
...
@@ -145,6 +145,21 @@ export class CommandCenter {
});
}
private
groupByModel
(
resources
:
Resource
[]):
[
Model
|
undefined
,
Resource
[]][]
{
return
resources
.
reduce
((
result
,
resource
)
=>
{
const
model
=
this
.
modelRegistry
.
getModel
(
resource
.
resourceUri
);
const
pair
=
result
.
filter
(
p
=>
p
[
0
]
===
model
)[
0
];
if
(
pair
)
{
pair
[
1
].
push
(
resource
);
}
else
{
result
.
push
([
model
,
[
resource
]]);
}
return
result
;
},
[]
as
[
Model
|
undefined
,
Resource
[]][]);
}
@
command
(
'
git.refresh
'
,
{
model
:
true
})
async
refresh
(
model
:
Model
):
Promise
<
void
>
{
await
model
.
status
();
...
...
@@ -321,7 +336,7 @@ export class CommandCenter {
if
(
!
(
resource
instanceof
Resource
))
{
// can happen when called from a keybinding
resource
=
this
.
getSCMResource
(
model
);
resource
=
this
.
getSCMResource
();
}
if
(
resource
)
{
...
...
@@ -363,9 +378,9 @@ export class CommandCenter {
if
(
arg
instanceof
Resource
)
{
resource
=
arg
;
}
else
if
(
arg
instanceof
Uri
)
{
resource
=
this
.
getSCMResource
(
model
,
arg
);
resource
=
this
.
getSCMResource
(
arg
);
}
else
{
resource
=
this
.
getSCMResource
(
model
);
resource
=
this
.
getSCMResource
();
}
if
(
!
resource
)
{
...
...
@@ -387,7 +402,7 @@ export class CommandCenter {
let
resources
:
Resource
[]
|
undefined
=
undefined
;
if
(
arg
instanceof
Uri
)
{
const
resource
=
this
.
getSCMResource
(
model
,
arg
);
const
resource
=
this
.
getSCMResource
(
arg
);
if
(
resource
!==
undefined
)
{
resources
=
[
resource
];
}
...
...
@@ -397,7 +412,7 @@ export class CommandCenter {
if
(
arg
instanceof
Resource
)
{
resource
=
arg
;
}
else
{
resource
=
this
.
getSCMResource
(
model
);
resource
=
this
.
getSCMResource
();
}
if
(
resource
)
{
...
...
@@ -415,10 +430,10 @@ export class CommandCenter {
}
}
@
command
(
'
git.stage
'
,
{
model
:
true
}
)
async
stage
(
model
:
Model
,
...
resourceStates
:
SourceControlResourceState
[]):
Promise
<
void
>
{
@
command
(
'
git.stage
'
)
async
stage
(...
resourceStates
:
SourceControlResourceState
[]):
Promise
<
void
>
{
if
(
resourceStates
.
length
===
0
||
!
(
resourceStates
[
0
].
resourceUri
instanceof
Uri
))
{
const
resource
=
this
.
getSCMResource
(
model
);
const
resource
=
this
.
getSCMResource
();
if
(
!
resource
)
{
return
;
...
...
@@ -434,7 +449,13 @@ export class CommandCenter {
return
;
}
return
await
model
.
add
(...
resources
);
await
Promise
.
all
(
this
.
groupByModel
(
resources
).
map
(
async
([
model
,
resources
])
=>
{
if
(
!
model
)
{
return
;
}
await
model
.
add
(...
resources
);
}));
}
@
command
(
'
git.stageAll
'
,
{
model
:
true
})
...
...
@@ -523,7 +544,7 @@ export class CommandCenter {
@
command
(
'
git.unstage
'
,
{
model
:
true
})
async
unstage
(
model
:
Model
,
...
resourceStates
:
SourceControlResourceState
[]):
Promise
<
void
>
{
if
(
resourceStates
.
length
===
0
||
!
(
resourceStates
[
0
].
resourceUri
instanceof
Uri
))
{
const
resource
=
this
.
getSCMResource
(
model
);
const
resource
=
this
.
getSCMResource
();
if
(
!
resource
)
{
return
;
...
...
@@ -589,7 +610,7 @@ export class CommandCenter {
@
command
(
'
git.clean
'
,
{
model
:
true
})
async
clean
(
model
:
Model
,
...
resourceStates
:
SourceControlResourceState
[]):
Promise
<
void
>
{
if
(
resourceStates
.
length
===
0
||
!
(
resourceStates
[
0
].
resourceUri
instanceof
Uri
))
{
const
resource
=
this
.
getSCMResource
(
model
);
const
resource
=
this
.
getSCMResource
();
if
(
!
resource
)
{
return
;
...
...
@@ -1164,7 +1185,8 @@ export class CommandCenter {
return
result
;
}
private
getSCMResource
(
model
:
Model
,
uri
?:
Uri
):
Resource
|
undefined
{
// TODO@Joao: possibly remove? do we really need to return resources?
private
getSCMResource
(
uri
?:
Uri
):
Resource
|
undefined
{
uri
=
uri
?
uri
:
window
.
activeTextEditor
&&
window
.
activeTextEditor
.
document
.
uri
;
if
(
!
uri
)
{
...
...
@@ -1178,6 +1200,11 @@ export class CommandCenter {
if
(
uri
.
scheme
===
'
file
'
)
{
const
uriString
=
uri
.
toString
();
const
model
=
this
.
modelRegistry
.
getModel
(
uri
);
if
(
!
model
)
{
return
undefined
;
}
return
model
.
workingTreeGroup
.
resources
.
filter
(
r
=>
r
.
resourceUri
.
toString
()
===
uriString
)[
0
]
||
model
.
indexGroup
.
resources
.
filter
(
r
=>
r
.
resourceUri
.
toString
()
===
uriString
)[
0
];
...
...
extensions/git/src/modelRegistry.ts
浏览文件 @
b9eb8bae
...
...
@@ -35,7 +35,7 @@ export class ModelRegistry {
return
pick
&&
pick
.
model
;
}
async
resolve
(
resource
:
Uri
):
Promise
<
Model
|
undefined
>
{
getModel
(
resource
:
Uri
):
Model
|
undefined
{
const
resourcePath
=
resource
.
fsPath
;
for
(
let
[
repositoryRoot
,
model
]
of
this
.
models
)
{
...
...
@@ -47,6 +47,16 @@ export class ModelRegistry {
}
}
return
undefined
;
}
async
resolve
(
resource
:
Uri
):
Promise
<
Model
|
undefined
>
{
const
model
=
this
.
getModel
(
resource
);
if
(
model
)
{
return
model
;
}
const
picks
=
Array
.
from
(
this
.
models
.
entries
(),
([
uri
,
model
])
=>
new
ModelPick
(
uri
,
model
));
const
placeHolder
=
localize
(
'
pick repo
'
,
"
Choose a repository
"
);
const
pick
=
await
window
.
showQuickPick
(
picks
,
{
placeHolder
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录