Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb04eaa1
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,发现更多精彩内容 >>
提交
eb04eaa1
编写于
8月 16, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: contextual repositories
上级
4a1bd6fb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
95 deletion
+35
-95
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+13
-74
extensions/git/src/model.ts
extensions/git/src/model.ts
+22
-21
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
eb04eaa1
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
Uri
,
commands
,
scm
,
Disposable
,
window
,
workspace
,
QuickPickItem
,
OutputChannel
,
Range
,
WorkspaceEdit
,
Position
,
LineChange
,
SourceControl
,
SourceControlResourceGroup
,
SourceControl
ResourceState
,
TextDocumentShowOptions
,
ViewColumn
}
from
'
vscode
'
;
import
{
Uri
,
commands
,
scm
,
Disposable
,
window
,
workspace
,
QuickPickItem
,
OutputChannel
,
Range
,
WorkspaceEdit
,
Position
,
LineChange
,
SourceControlResourceState
,
TextDocumentShowOptions
,
ViewColumn
}
from
'
vscode
'
;
import
{
Ref
,
RefType
,
Git
,
GitErrorCodes
,
Branch
}
from
'
./git
'
;
import
{
Repository
,
Resource
,
Status
,
CommitOptions
,
ResourceGroupType
}
from
'
./repository
'
;
import
{
Model
}
from
'
./model
'
;
...
...
@@ -145,22 +145,8 @@ export class CommandCenter {
});
}
@
command
(
'
git.refresh
'
)
async
refresh
(
sourceControl
?:
SourceControl
):
Promise
<
void
>
{
let
repository
:
Repository
|
undefined
=
undefined
;
if
(
sourceControl
)
{
repository
=
this
.
model
.
getRepositoryFromSourceControl
(
sourceControl
);
}
if
(
!
repository
)
{
repository
=
await
this
.
model
.
pickRepository
();
}
if
(
!
repository
)
{
return
;
}
@
command
(
'
git.refresh
'
,
{
repository
:
true
})
async
refresh
(
repository
:
Repository
):
Promise
<
void
>
{
await
repository
.
status
();
}
...
...
@@ -458,22 +444,8 @@ export class CommandCenter {
await
this
.
runByRepository
(
resources
,
async
(
repository
,
resources
)
=>
repository
.
add
(
resources
));
}
@
command
(
'
git.stageAll
'
)
async
stageAll
(
group
?:
SourceControlResourceGroup
):
Promise
<
void
>
{
let
repository
:
Repository
|
undefined
=
undefined
;
if
(
group
)
{
repository
=
this
.
model
.
getRepositoryFromResourceGroup
(
group
);
}
if
(
!
repository
)
{
repository
=
await
this
.
model
.
pickRepository
();
}
if
(
!
repository
)
{
return
;
}
@
command
(
'
git.stageAll
'
,
{
repository
:
true
})
async
stageAll
(
repository
:
Repository
):
Promise
<
void
>
{
await
repository
.
add
([]);
}
...
...
@@ -576,22 +548,8 @@ export class CommandCenter {
await
this
.
runByRepository
(
resources
,
async
(
repository
,
resources
)
=>
repository
.
revert
(
resources
));
}
@
command
(
'
git.unstageAll
'
)
async
unstageAll
(
group
?:
SourceControlResourceGroup
):
Promise
<
void
>
{
let
repository
:
Repository
|
undefined
=
undefined
;
if
(
group
)
{
repository
=
this
.
model
.
getRepositoryFromResourceGroup
(
group
);
}
if
(
!
repository
)
{
repository
=
await
this
.
model
.
pickRepository
();
}
if
(
!
repository
)
{
return
;
}
@
command
(
'
git.unstageAll
'
,
{
repository
:
true
})
async
unstageAll
(
repository
:
Repository
):
Promise
<
void
>
{
await
repository
.
revert
([]);
}
...
...
@@ -681,22 +639,8 @@ export class CommandCenter {
await
this
.
runByRepository
(
resources
,
async
(
repository
,
resources
)
=>
repository
.
clean
(
resources
));
}
@
command
(
'
git.cleanAll
'
)
async
cleanAll
(
group
?:
SourceControlResourceGroup
):
Promise
<
void
>
{
let
repository
:
Repository
|
undefined
=
undefined
;
if
(
group
)
{
repository
=
this
.
model
.
getRepositoryFromResourceGroup
(
group
);
}
if
(
!
repository
)
{
repository
=
await
this
.
model
.
pickRepository
();
}
if
(
!
repository
)
{
return
;
}
@
command
(
'
git.cleanAll
'
,
{
repository
:
true
})
async
cleanAll
(
repository
:
Repository
):
Promise
<
void
>
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
let
scope
=
config
.
get
<
string
>
(
'
discardAllScope
'
)
||
'
prompt
'
;
let
resources
=
repository
.
workingTreeGroup
.
resourceStates
;
...
...
@@ -1263,21 +1207,16 @@ export class CommandCenter {
private
createCommand
(
id
:
string
,
key
:
string
,
method
:
Function
,
options
:
CommandOptions
):
(...
args
:
any
[])
=>
any
{
const
result
=
(...
args
)
=>
{
// if (!skipModelCheck && !this.model) {
// window.showInformationMessage(localize('disabled', "Git is either disabled or not supported in this workspace"));
// return;
// }
let
result
:
Promise
<
any
>
;
if
(
!
options
.
repository
)
{
result
=
Promise
.
resolve
(
method
.
apply
(
this
,
args
));
}
else
{
console
.
log
(
args
[
0
]);
// if (args[0] instanceof SourceControlResourceGroup) {
// }
// try to guess the repository based on the first argument
const
repository
=
this
.
model
.
getRepository
(
args
[
0
]);
const
repositoryPromise
=
repository
?
Promise
.
resolve
(
repository
)
:
this
.
model
.
pickRepository
();
result
=
this
.
model
.
pickRepository
()
.
then
(
repository
=>
{
result
=
repositoryPromise
.
then
(
repository
=>
{
if
(
!
repository
)
{
return
Promise
.
reject
(
localize
(
'
modelnotfound
'
,
"
Git model not found
"
));
}
...
...
extensions/git/src/model.ts
浏览文件 @
eb04eaa1
...
...
@@ -60,34 +60,35 @@ export class Model {
return
pick
&&
pick
.
repository
;
}
getRepositoryFromSourceControl
(
sourceControl
:
SourceControl
):
Repository
|
undefined
{
for
(
let
[,
repository
]
of
this
.
repositories
)
{
if
(
sourceControl
===
repository
.
sourceControl
)
{
return
repository
;
}
getRepository
(
sourceControl
:
SourceControl
):
Repository
|
undefined
;
getRepository
(
resourceGroup
:
SourceControlResourceGroup
):
Repository
|
undefined
;
getRepository
(
resource
:
Uri
):
Repository
|
undefined
;
getRepository
(
hint
:
any
):
Repository
|
undefined
{
if
(
!
hint
)
{
return
undefined
;
}
return
undefined
;
}
if
(
hint
instanceof
Uri
)
{
const
resourcePath
=
hint
.
fsPath
;
getRepositoryFromResourceGroup
(
resourceGroup
:
SourceControlResourceGroup
):
Repository
|
undefined
{
for
(
let
[,
repository
]
of
this
.
repositories
)
{
if
(
resourceGroup
===
repository
.
mergeGroup
||
resourceGroup
===
repository
.
indexGroup
||
resourceGroup
===
repository
.
workingTreeGroup
)
{
return
repository
;
}
}
for
(
let
[
root
,
repository
]
of
this
.
repositories
)
{
const
repositoryRootPath
=
root
.
fsPath
;
const
relativePath
=
path
.
relative
(
repositoryRootPath
,
resourcePath
);
return
undefined
;
}
if
(
!
/^
\.
/
.
test
(
relativePath
))
{
return
repository
;
}
}
getRepository
(
resource
:
Uri
):
Repository
|
undefined
{
const
resourcePath
=
resource
.
fsPath
;
return
undefined
;
}
for
(
let
[
root
,
repository
]
of
this
.
repositories
)
{
const
repositoryRootPath
=
root
.
fsPath
;
const
relativePath
=
path
.
relative
(
repositoryRootPath
,
resourcePath
);
for
(
let
[,
repository
]
of
this
.
repositories
)
{
if
(
hint
===
repository
.
sourceControl
)
{
return
repository
;
}
if
(
!
/^
\.
/
.
test
(
relativePath
)
)
{
if
(
hint
===
repository
.
mergeGroup
||
hint
===
repository
.
indexGroup
||
hint
===
repository
.
workingTreeGroup
)
{
return
repository
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录