Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fe8ee2e7
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,发现更多精彩内容 >>
提交
fe8ee2e7
编写于
8月 15, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: repository == scm provider
上级
56d1dadf
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
341 addition
and
437 deletion
+341
-437
extensions/git/package.json
extensions/git/package.json
+85
-85
extensions/git/src/autofetch.ts
extensions/git/src/autofetch.ts
+2
-2
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+128
-128
extensions/git/src/contentProvider.ts
extensions/git/src/contentProvider.ts
+4
-4
extensions/git/src/main.ts
extensions/git/src/main.ts
+0
-5
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+106
-77
extensions/git/src/scmProvider.ts
extensions/git/src/scmProvider.ts
+0
-120
extensions/git/src/statusbar.ts
extensions/git/src/statusbar.ts
+16
-16
未找到文件。
extensions/git/package.json
浏览文件 @
fe8ee2e7
...
...
@@ -276,393 +276,393 @@
},
{
"command"
:
"git.init"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == norepo
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.refresh"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.openFile"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.openHEADFile"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.openChange"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.stageSelectedRanges"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.revertSelectedRanges"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.unstage"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.unstageAll"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.unstageSelectedRanges"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.clean"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.cleanAll"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commit"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commitStaged"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commitStagedSigned"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commitStagedAmend"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commitAll"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commitAllSigned"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.commitAllAmend"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.undoCommit"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.checkout"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.branch"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.deleteBranch"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.pull"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.pullFrom"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.pullRebase"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.pullFrom"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.createTag"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.push"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.pushTo"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.pushWithTags"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.sync"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.publish"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.showOutput"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.stash"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.stashPop"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
},
{
"command"
:
"git.stashPopLatest"
,
"when"
:
"config.git.enabled
&& scmProvider == git && gitState == idle
"
"when"
:
"config.git.enabled"
}
],
"scm/title"
:
[
{
"command"
:
"git.init"
,
"group"
:
"navigation"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == norepo
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commit"
,
"group"
:
"navigation"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.refresh"
,
"group"
:
"navigation"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.sync"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.pull"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.pullRebase"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.pullFrom"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.push"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.pushTo"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.publish"
,
"group"
:
"2_publish"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commitStaged"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commitStagedSigned"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commitStagedAmend"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commitAll"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commitAllSigned"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.commitAllAmend"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.undoCommit"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.unstageAll"
,
"group"
:
"4_stage"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.cleanAll"
,
"group"
:
"4_stage"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.showOutput"
,
"group"
:
"6_output"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.stash"
,
"group"
:
"5_stash"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.stashPop"
,
"group"
:
"5_stash"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
},
{
"command"
:
"git.stashPopLatest"
,
"group"
:
"5_stash"
,
"when"
:
"config.git.enabled && scmProvider == git
&& gitState == idle
"
"when"
:
"config.git.enabled && scmProvider == git"
}
],
"scm/resourceGroup/context"
:
[
{
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == merge"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == merge"
,
"group"
:
"inline"
},
{
"command"
:
"git.unstageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.unstageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"inline"
},
{
"command"
:
"git.cleanAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.cleanAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"inline"
},
{
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"inline"
}
],
"scm/resourceState/context"
:
[
{
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == merge"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == merge"
,
"group"
:
"inline"
},
{
"command"
:
"git.openChange"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"navigation"
},
{
"command"
:
"git.openFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"navigation"
},
{
"command"
:
"git.openHEADFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"navigation"
},
{
"command"
:
"git.unstage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.unstage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == index"
,
"group"
:
"inline"
},
{
"command"
:
"git.openChange"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"navigation"
},
{
"command"
:
"git.openHEADFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"navigation"
},
{
"command"
:
"git.openFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"navigation"
},
{
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.clean"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
},
{
"command"
:
"git.clean"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"inline"
},
{
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"inline"
},
{
"command"
:
"git.ignore"
,
"when"
:
"config.git.enabled && scmProvider == git &&
gitState == idle &&
scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git && scmResourceGroup == workingTree"
,
"group"
:
"1_modification@3"
}
],
...
...
extensions/git/src/autofetch.ts
浏览文件 @
fe8ee2e7
...
...
@@ -16,7 +16,7 @@ export class AutoFetcher {
private
disposables
:
Disposable
[]
=
[];
private
timer
:
NodeJS
.
Timer
;
constructor
(
private
model
:
Repository
)
{
constructor
(
private
repository
:
Repository
)
{
workspace
.
onDidChangeConfiguration
(
this
.
onConfiguration
,
this
,
this
.
disposables
);
this
.
onConfiguration
();
}
...
...
@@ -47,7 +47,7 @@ export class AutoFetcher {
@
throttle
private
async
fetch
():
Promise
<
void
>
{
try
{
await
this
.
model
.
fetch
();
await
this
.
repository
.
fetch
();
}
catch
(
err
)
{
if
(
err
.
gitErrorCode
===
GitErrorCodes
.
AuthenticationFailed
)
{
this
.
disable
();
...
...
extensions/git/src/commands.ts
浏览文件 @
fe8ee2e7
此差异已折叠。
点击以展开。
extensions/git/src/contentProvider.ts
浏览文件 @
fe8ee2e7
...
...
@@ -30,9 +30,9 @@ export class GitContentProvider {
private
cache
:
Cache
=
Object
.
create
(
null
);
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
model
:
Repository
)
{
constructor
(
private
repository
:
Repository
)
{
this
.
disposables
.
push
(
model
.
onDidChangeRepository
(
this
.
eventuallyFireChangeEvents
,
this
),
repository
.
onDidChangeRepository
(
this
.
eventuallyFireChangeEvents
,
this
),
workspace
.
registerTextDocumentContentProvider
(
'
git
'
,
this
)
);
...
...
@@ -61,12 +61,12 @@ export class GitContentProvider {
if
(
ref
===
'
~
'
)
{
const
fileUri
=
Uri
.
file
(
path
);
const
uriString
=
fileUri
.
toString
();
const
[
indexStatus
]
=
this
.
model
.
indexGroup
.
resourc
es
.
filter
(
r
=>
r
.
original
.
toString
()
===
uriString
);
const
[
indexStatus
]
=
this
.
repository
.
indexGroup
.
resourceStat
es
.
filter
(
r
=>
r
.
original
.
toString
()
===
uriString
);
ref
=
indexStatus
?
''
:
'
HEAD
'
;
}
try
{
return
await
this
.
model
.
show
(
ref
,
path
);
return
await
this
.
repository
.
show
(
ref
,
path
);
}
catch
(
err
)
{
return
''
;
}
...
...
extensions/git/src/main.ts
浏览文件 @
fe8ee2e7
...
...
@@ -11,9 +11,7 @@ import { ExtensionContext, workspace, window, Disposable, commands, Uri } from '
import
{
findGit
,
Git
,
IGit
}
from
'
./git
'
;
import
{
Repository
}
from
'
./repository
'
;
import
{
Model
}
from
'
./model
'
;
import
{
GitSCMProvider
}
from
'
./scmProvider
'
;
import
{
CommandCenter
}
from
'
./commands
'
;
import
{
StatusBarCommands
}
from
'
./statusbar
'
;
import
{
GitContentProvider
}
from
'
./contentProvider
'
;
import
{
AutoFetcher
}
from
'
./autofetch
'
;
import
{
Askpass
}
from
'
./askpass
'
;
...
...
@@ -56,14 +54,11 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
disposables
.
push
(
toDisposable
(()
=>
git
.
onOutput
.
removeListener
(
'
log
'
,
onOutput
)));
const
commandCenter
=
new
CommandCenter
(
git
,
model
,
outputChannel
,
telemetryReporter
);
const
statusBarCommands
=
new
StatusBarCommands
(
repository
);
const
provider
=
new
GitSCMProvider
(
repository
,
statusBarCommands
);
const
contentProvider
=
new
GitContentProvider
(
repository
);
const
autoFetcher
=
new
AutoFetcher
(
repository
);
disposables
.
push
(
commandCenter
,
provider
,
contentProvider
,
autoFetcher
,
repository
...
...
extensions/git/src/repository.ts
浏览文件 @
fe8ee2e7
...
...
@@ -5,10 +5,11 @@
'
use strict
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
}
from
'
vscode
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
commands
,
SourceControl
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
}
from
'
vscode
'
;
import
{
Git
,
Repository
as
BaseRepository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
,
Stash
}
from
'
./git
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
,
find
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
{
toGitUri
}
from
'
./uri
'
;
import
*
as
path
from
'
path
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
*
as
fs
from
'
fs
'
;
...
...
@@ -49,6 +50,12 @@ export enum Status {
BOTH_MODIFIED
}
export
enum
ResourceGroupType
{
Merge
,
Index
,
WorkingTree
}
export
class
Resource
implements
SourceControlResourceState
{
@
memoize
...
...
@@ -69,7 +76,7 @@ export class Resource implements SourceControlResourceState {
};
}
get
resourceGroup
():
ResourceGroup
{
return
this
.
_resourceGroup
;
}
get
resourceGroup
Type
():
ResourceGroupType
{
return
this
.
_resourceGroupType
;
}
get
type
():
Status
{
return
this
.
_type
;
}
get
original
():
Uri
{
return
this
.
_resourceUri
;
}
get
renameResourceUri
():
Uri
|
undefined
{
return
this
.
_renameResourceUri
;
}
...
...
@@ -149,52 +156,13 @@ export class Resource implements SourceControlResourceState {
constructor
(
private
workspaceRoot
:
Uri
,
private
_resourceGroup
:
ResourceGroup
,
private
_resourceGroup
Type
:
ResourceGroupType
,
private
_resourceUri
:
Uri
,
private
_type
:
Status
,
private
_renameResourceUri
?:
Uri
)
{
}
}
export
abstract
class
ResourceGroup
{
get
id
():
string
{
return
this
.
_id
;
}
get
contextKey
():
string
{
return
this
.
_id
;
}
get
label
():
string
{
return
this
.
_label
;
}
get
resources
():
Resource
[]
{
return
this
.
_resources
;
}
constructor
(
private
_id
:
string
,
private
_label
:
string
,
private
_resources
:
Resource
[])
{
}
}
export
class
MergeGroup
extends
ResourceGroup
{
static
readonly
ID
=
'
merge
'
;
constructor
(
resources
:
Resource
[]
=
[])
{
super
(
MergeGroup
.
ID
,
localize
(
'
merge changes
'
,
"
Merge Changes
"
),
resources
);
}
}
export
class
IndexGroup
extends
ResourceGroup
{
static
readonly
ID
=
'
index
'
;
constructor
(
resources
:
Resource
[]
=
[])
{
super
(
IndexGroup
.
ID
,
localize
(
'
staged changes
'
,
"
Staged Changes
"
),
resources
);
}
}
export
class
WorkingTreeGroup
extends
ResourceGroup
{
static
readonly
ID
=
'
workingTree
'
;
constructor
(
resources
:
Resource
[]
=
[])
{
super
(
WorkingTreeGroup
.
ID
,
localize
(
'
changes
'
,
"
Changes
"
),
resources
);
}
}
export
enum
Operation
{
Status
=
1
<<
0
,
Add
=
1
<<
1
,
...
...
@@ -302,6 +270,10 @@ export interface IRepository {
clean
(
resources
:
Uri
[]):
Promise
<
void
>
;
}
export
interface
GitResourceGroup
extends
SourceControlResourceGroup
{
resourceStates
:
Resource
[];
}
export
class
Repository
implements
IRepository
,
Disposable
{
private
_onDidChangeRepository
=
new
EventEmitter
<
Uri
>
();
...
...
@@ -310,12 +282,9 @@ export class Repository implements IRepository, Disposable {
private
_onDidChangeState
=
new
EventEmitter
<
State
>
();
readonly
onDidChangeState
:
Event
<
State
>
=
this
.
_onDidChangeState
.
event
;
private
_onDidChangeResources
=
new
EventEmitter
<
void
>
();
readonly
onDidChangeResources
:
Event
<
void
>
=
this
.
_onDidChangeResources
.
event
;
@
memoize
get
onDidChange
():
Event
<
void
>
{
return
anyEvent
<
any
>
(
this
.
onDidChangeState
,
this
.
onDidChangeResources
);
return
anyEvent
<
any
>
(
this
.
onDidChangeState
);
}
private
_onRunOperation
=
new
EventEmitter
<
Operation
>
();
...
...
@@ -329,14 +298,17 @@ export class Repository implements IRepository, Disposable {
return
anyEvent
(
this
.
onRunOperation
as
Event
<
any
>
,
this
.
onDidRunOperation
as
Event
<
any
>
);
}
private
_mergeGroup
=
new
MergeGroup
([]);
get
mergeGroup
():
MergeGroup
{
return
this
.
_mergeGroup
;
}
private
_sourceControl
:
SourceControl
;
get
sourceControl
():
SourceControl
{
return
this
.
_sourceControl
;
}
private
_mergeGroup
:
SourceControlResourceGroup
;
get
mergeGroup
():
GitResourceGroup
{
return
this
.
_mergeGroup
as
GitResourceGroup
;
}
private
_indexGroup
=
new
IndexGroup
([])
;
get
indexGroup
():
IndexGroup
{
return
this
.
_index
Group
;
}
private
_indexGroup
:
SourceControlResourceGroup
;
get
indexGroup
():
GitResourceGroup
{
return
this
.
_indexGroup
as
GitResource
Group
;
}
private
_workingTreeGroup
=
new
WorkingTreeGroup
([])
;
get
workingTreeGroup
():
WorkingTreeGroup
{
return
this
.
_workingTre
eGroup
;
}
private
_workingTreeGroup
:
SourceControlResourceGroup
;
get
workingTreeGroup
():
GitResourceGroup
{
return
this
.
_workingTreeGroup
as
GitResourc
eGroup
;
}
private
_HEAD
:
Branch
|
undefined
;
get
HEAD
():
Branch
|
undefined
{
...
...
@@ -367,10 +339,11 @@ export class Repository implements IRepository, Disposable {
this
.
_HEAD
=
undefined
;
this
.
_refs
=
[];
this
.
_remotes
=
[];
this
.
_mergeGroup
=
new
MergeGroup
();
this
.
_indexGroup
=
new
IndexGroup
();
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
();
this
.
_onDidChangeResources
.
fire
();
this
.
mergeGroup
.
resourceStates
=
[];
this
.
indexGroup
.
resourceStates
=
[];
this
.
workingTreeGroup
.
resourceStates
=
[];
this
.
_sourceControl
.
count
=
0
;
commands
.
executeCommand
(
'
setContext
'
,
'
gitState
'
,
''
);
}
private
onWorkspaceChange
:
Event
<
Uri
>
;
...
...
@@ -387,9 +360,43 @@ export class Repository implements IRepository, Disposable {
this
.
onWorkspaceChange
=
anyEvent
(
fsWatcher
.
onDidChange
,
fsWatcher
.
onDidCreate
,
fsWatcher
.
onDidDelete
);
this
.
disposables
.
push
(
fsWatcher
);
this
.
_sourceControl
=
scm
.
createSourceControl
(
'
git
'
,
'
Git
'
);
this
.
_sourceControl
.
acceptInputCommand
=
{
command
:
'
git.commitWithInput
'
,
title
:
localize
(
'
commit
'
,
"
Commit
"
)
};
this
.
_sourceControl
.
quickDiffProvider
=
this
;
this
.
disposables
.
push
(
this
.
_sourceControl
);
this
.
_mergeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
'
merge
'
,
localize
(
'
merge changes
'
,
"
Merge Changes
"
));
this
.
_indexGroup
=
this
.
_sourceControl
.
createResourceGroup
(
'
index
'
,
localize
(
'
staged changes
'
,
"
Staged Changes
"
));
this
.
_workingTreeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
'
workingTree
'
,
localize
(
'
changes
'
,
"
Changes
"
));
this
.
mergeGroup
.
hideWhenEmpty
=
true
;
this
.
indexGroup
.
hideWhenEmpty
=
true
;
this
.
disposables
.
push
(
this
.
mergeGroup
);
this
.
disposables
.
push
(
this
.
indexGroup
);
this
.
disposables
.
push
(
this
.
workingTreeGroup
);
this
.
updateCommitTemplate
();
this
.
status
();
}
// TODO@Joao reorganize this
provideOriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
if
(
uri
.
scheme
!==
'
file
'
)
{
return
;
}
return
toGitUri
(
uri
,
''
,
true
);
}
private
async
updateCommitTemplate
():
Promise
<
void
>
{
try
{
this
.
_sourceControl
.
commitTemplate
=
await
this
.
repository
.
getCommitTemplate
();
}
catch
(
e
)
{
// noop
}
}
@
throttle
async
init
():
Promise
<
void
>
{
if
(
this
.
state
!==
State
.
NotAGitRepository
)
{
...
...
@@ -435,7 +442,7 @@ export class Repository implements IRepository, Disposable {
resources
.
forEach
(
r
=>
{
const
raw
=
r
.
toString
();
const
scmResource
=
find
(
this
.
workingTreeGroup
.
resources
,
sr
=>
sr
.
resourceUri
.
toString
()
===
raw
);
const
scmResource
=
find
(
this
.
workingTreeGroup
.
resource
State
s
,
sr
=>
sr
.
resourceUri
.
toString
()
===
raw
);
if
(
!
scmResource
)
{
return
;
...
...
@@ -731,37 +738,59 @@ export class Repository implements IRepository, Disposable {
const
renameUri
=
raw
.
rename
?
Uri
.
file
(
path
.
join
(
this
.
repository
.
root
,
raw
.
rename
))
:
undefined
;
switch
(
raw
.
x
+
raw
.
y
)
{
case
'
??
'
:
return
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
workingTreeGroup
,
uri
,
Status
.
UNTRACKED
));
case
'
!!
'
:
return
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
workingTreeGroup
,
uri
,
Status
.
IGNORED
));
case
'
DD
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
BOTH_DELETED
));
case
'
AU
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
ADDED_BY_US
));
case
'
UD
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
DELETED_BY_THEM
));
case
'
UA
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
ADDED_BY_THEM
));
case
'
DU
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
DELETED_BY_US
));
case
'
AA
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
BOTH_ADDED
));
case
'
UU
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
mergeGroup
,
uri
,
Status
.
BOTH_MODIFIED
));
case
'
??
'
:
return
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
WorkingTree
,
uri
,
Status
.
UNTRACKED
));
case
'
!!
'
:
return
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
WorkingTree
,
uri
,
Status
.
IGNORED
));
case
'
DD
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
BOTH_DELETED
));
case
'
AU
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
ADDED_BY_US
));
case
'
UD
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
DELETED_BY_THEM
));
case
'
UA
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
ADDED_BY_THEM
));
case
'
DU
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
DELETED_BY_US
));
case
'
AA
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
BOTH_ADDED
));
case
'
UU
'
:
return
merge
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Merge
,
uri
,
Status
.
BOTH_MODIFIED
));
}
let
isModifiedInIndex
=
false
;
switch
(
raw
.
x
)
{
case
'
M
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
indexGroup
,
uri
,
Status
.
INDEX_MODIFIED
));
isModifiedInIndex
=
true
;
break
;
case
'
A
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
indexGroup
,
uri
,
Status
.
INDEX_ADDED
));
break
;
case
'
D
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
indexGroup
,
uri
,
Status
.
INDEX_DELETED
));
break
;
case
'
R
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
indexGroup
,
uri
,
Status
.
INDEX_RENAMED
,
renameUri
));
break
;
case
'
C
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
indexGroup
,
uri
,
Status
.
INDEX_COPIED
,
renameUri
));
break
;
case
'
M
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Index
,
uri
,
Status
.
INDEX_MODIFIED
));
isModifiedInIndex
=
true
;
break
;
case
'
A
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Index
,
uri
,
Status
.
INDEX_ADDED
));
break
;
case
'
D
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Index
,
uri
,
Status
.
INDEX_DELETED
));
break
;
case
'
R
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Index
,
uri
,
Status
.
INDEX_RENAMED
,
renameUri
));
break
;
case
'
C
'
:
index
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
Index
,
uri
,
Status
.
INDEX_COPIED
,
renameUri
));
break
;
}
switch
(
raw
.
y
)
{
case
'
M
'
:
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
workingTreeGroup
,
uri
,
Status
.
MODIFIED
,
renameUri
));
break
;
case
'
D
'
:
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
this
.
workingTreeGroup
,
uri
,
Status
.
DELETED
,
renameUri
));
break
;
case
'
M
'
:
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
WorkingTree
,
uri
,
Status
.
MODIFIED
,
renameUri
));
break
;
case
'
D
'
:
workingTree
.
push
(
new
Resource
(
this
.
workspaceRoot
,
ResourceGroupType
.
WorkingTree
,
uri
,
Status
.
DELETED
,
renameUri
));
break
;
}
});
this
.
_mergeGroup
=
new
MergeGroup
(
merge
);
this
.
_indexGroup
=
new
IndexGroup
(
index
);
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
(
workingTree
);
this
.
_onDidChangeResources
.
fire
();
// set resource groups
this
.
mergeGroup
.
resourceStates
=
merge
;
this
.
indexGroup
.
resourceStates
=
index
;
this
.
workingTreeGroup
.
resourceStates
=
workingTree
;
// set count badge
const
countBadge
=
workspace
.
getConfiguration
(
'
git
'
).
get
<
string
>
(
'
countBadge
'
);
let
count
=
merge
.
length
+
index
.
length
+
workingTree
.
length
;
switch
(
countBadge
)
{
case
'
off
'
:
count
=
0
;
break
;
case
'
tracked
'
:
count
=
count
-
workingTree
.
filter
(
r
=>
r
.
type
===
Status
.
UNTRACKED
||
r
.
type
===
Status
.
IGNORED
).
length
;
break
;
}
this
.
_sourceControl
.
count
=
count
;
// set context key
let
stateContextKey
=
''
;
switch
(
this
.
state
)
{
case
State
.
Uninitialized
:
stateContextKey
=
'
uninitialized
'
;
break
;
case
State
.
Idle
:
stateContextKey
=
'
idle
'
;
break
;
case
State
.
NotAGitRepository
:
stateContextKey
=
'
norepo
'
;
break
;
}
commands
.
executeCommand
(
'
setContext
'
,
'
gitState
'
,
stateContextKey
);
}
private
onFSChange
(
uri
:
Uri
):
void
{
...
...
extensions/git/src/scmProvider.ts
已删除
100644 → 0
浏览文件 @
56d1dadf
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
scm
,
Uri
,
Disposable
,
SourceControl
,
SourceControlResourceGroup
,
Event
,
workspace
,
commands
}
from
'
vscode
'
;
import
{
Repository
,
State
,
Status
}
from
'
./repository
'
;
import
{
StatusBarCommands
}
from
'
./statusbar
'
;
import
{
mapEvent
}
from
'
./util
'
;
import
{
toGitUri
}
from
'
./uri
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
export
class
GitSCMProvider
{
private
disposables
:
Disposable
[]
=
[];
get
contextKey
():
string
{
return
'
git
'
;
}
get
onDidChange
():
Event
<
this
>
{
return
mapEvent
(
this
.
model
.
onDidChange
,
()
=>
this
);
}
get
label
():
string
{
return
'
Git
'
;
}
get
stateContextKey
():
string
{
switch
(
this
.
model
.
state
)
{
case
State
.
Uninitialized
:
return
'
uninitialized
'
;
case
State
.
Idle
:
return
'
idle
'
;
case
State
.
NotAGitRepository
:
return
'
norepo
'
;
default
:
return
''
;
}
}
get
count
():
number
{
const
countBadge
=
workspace
.
getConfiguration
(
'
git
'
).
get
<
string
>
(
'
countBadge
'
);
const
total
=
this
.
model
.
mergeGroup
.
resources
.
length
+
this
.
model
.
indexGroup
.
resources
.
length
+
this
.
model
.
workingTreeGroup
.
resources
.
length
;
switch
(
countBadge
)
{
case
'
off
'
:
return
0
;
case
'
tracked
'
:
return
total
-
this
.
model
.
workingTreeGroup
.
resources
.
filter
(
r
=>
r
.
type
===
Status
.
UNTRACKED
||
r
.
type
===
Status
.
IGNORED
).
length
;
default
:
return
total
;
}
}
private
_sourceControl
:
SourceControl
;
get
sourceControl
():
SourceControl
{
return
this
.
_sourceControl
;
}
private
mergeGroup
:
SourceControlResourceGroup
;
private
indexGroup
:
SourceControlResourceGroup
;
private
workingTreeGroup
:
SourceControlResourceGroup
;
constructor
(
private
model
:
Repository
,
private
statusBarCommands
:
StatusBarCommands
)
{
this
.
_sourceControl
=
scm
.
createSourceControl
(
'
git
'
,
'
Git
'
);
this
.
disposables
.
push
(
this
.
_sourceControl
);
this
.
_sourceControl
.
acceptInputCommand
=
{
command
:
'
git.commitWithInput
'
,
title
:
localize
(
'
commit
'
,
"
Commit
"
)
};
this
.
_sourceControl
.
quickDiffProvider
=
this
;
this
.
statusBarCommands
.
onDidChange
(
this
.
onDidStatusBarCommandsChange
,
this
,
this
.
disposables
);
this
.
onDidStatusBarCommandsChange
();
this
.
mergeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
model
.
mergeGroup
.
id
,
model
.
mergeGroup
.
label
);
this
.
indexGroup
=
this
.
_sourceControl
.
createResourceGroup
(
model
.
indexGroup
.
id
,
model
.
indexGroup
.
label
);
this
.
workingTreeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
model
.
workingTreeGroup
.
id
,
model
.
workingTreeGroup
.
label
);
this
.
mergeGroup
.
hideWhenEmpty
=
true
;
this
.
indexGroup
.
hideWhenEmpty
=
true
;
this
.
disposables
.
push
(
this
.
mergeGroup
);
this
.
disposables
.
push
(
this
.
indexGroup
);
this
.
disposables
.
push
(
this
.
workingTreeGroup
);
model
.
onDidChange
(
this
.
onDidModelChange
,
this
,
this
.
disposables
);
this
.
updateCommitTemplate
();
}
private
async
updateCommitTemplate
():
Promise
<
void
>
{
try
{
this
.
_sourceControl
.
commitTemplate
=
await
this
.
model
.
getCommitTemplate
();
}
catch
(
e
)
{
// noop
}
}
provideOriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
if
(
uri
.
scheme
!==
'
file
'
)
{
return
;
}
return
toGitUri
(
uri
,
''
,
true
);
}
private
onDidModelChange
():
void
{
this
.
mergeGroup
.
resourceStates
=
this
.
model
.
mergeGroup
.
resources
;
this
.
indexGroup
.
resourceStates
=
this
.
model
.
indexGroup
.
resources
;
this
.
workingTreeGroup
.
resourceStates
=
this
.
model
.
workingTreeGroup
.
resources
;
this
.
_sourceControl
.
count
=
this
.
count
;
commands
.
executeCommand
(
'
setContext
'
,
'
gitState
'
,
this
.
stateContextKey
);
}
private
onDidStatusBarCommandsChange
():
void
{
this
.
_sourceControl
.
statusBarCommands
=
this
.
statusBarCommands
.
commands
;
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
this
.
disposables
=
[];
}
}
\ No newline at end of file
extensions/git/src/statusbar.ts
浏览文件 @
fe8ee2e7
...
...
@@ -19,25 +19,25 @@ class CheckoutStatusBar {
get
onDidChange
():
Event
<
void
>
{
return
this
.
_onDidChange
.
event
;
}
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
model
:
Repository
)
{
model
.
onDidChange
(
this
.
_onDidChange
.
fire
,
this
.
_onDidChange
,
this
.
disposables
);
constructor
(
private
repository
:
Repository
)
{
repository
.
onDidChange
(
this
.
_onDidChange
.
fire
,
this
.
_onDidChange
,
this
.
disposables
);
}
get
command
():
Command
|
undefined
{
const
HEAD
=
this
.
model
.
HEAD
;
const
HEAD
=
this
.
repository
.
HEAD
;
if
(
!
HEAD
)
{
return
undefined
;
}
const
tag
=
this
.
model
.
refs
.
filter
(
iref
=>
iref
.
type
===
RefType
.
Tag
&&
iref
.
commit
===
HEAD
.
commit
)[
0
];
const
tag
=
this
.
repository
.
refs
.
filter
(
iref
=>
iref
.
type
===
RefType
.
Tag
&&
iref
.
commit
===
HEAD
.
commit
)[
0
];
const
tagName
=
tag
&&
tag
.
name
;
const
head
=
HEAD
.
name
||
tagName
||
(
HEAD
.
commit
||
''
).
substr
(
0
,
8
);
const
title
=
'
$(git-branch)
'
+
head
+
(
this
.
model
.
workingTreeGroup
.
resourc
es
.
length
>
0
?
'
*
'
:
''
)
+
(
this
.
model
.
indexGroup
.
resourc
es
.
length
>
0
?
'
+
'
:
''
)
+
(
this
.
model
.
mergeGroup
.
resourc
es
.
length
>
0
?
'
!
'
:
''
);
+
(
this
.
repository
.
workingTreeGroup
.
resourceStat
es
.
length
>
0
?
'
*
'
:
''
)
+
(
this
.
repository
.
indexGroup
.
resourceStat
es
.
length
>
0
?
'
+
'
:
''
)
+
(
this
.
repository
.
mergeGroup
.
resourceStat
es
.
length
>
0
?
'
!
'
:
''
);
return
{
command
:
'
git.checkout
'
,
...
...
@@ -76,24 +76,24 @@ class SyncStatusBar {
this
.
_onDidChange
.
fire
();
}
constructor
(
private
model
:
Repository
)
{
model
.
onDidChange
(
this
.
onModelChange
,
this
,
this
.
disposables
);
model
.
onDidChangeOperations
(
this
.
onOperationsChange
,
this
,
this
.
disposables
);
constructor
(
private
repository
:
Repository
)
{
repository
.
onDidChange
(
this
.
onModelChange
,
this
,
this
.
disposables
);
repository
.
onDidChangeOperations
(
this
.
onOperationsChange
,
this
,
this
.
disposables
);
this
.
_onDidChange
.
fire
();
}
private
onOperationsChange
():
void
{
this
.
state
=
{
...
this
.
state
,
isSyncRunning
:
this
.
model
.
operations
.
isRunning
(
Operation
.
Sync
)
isSyncRunning
:
this
.
repository
.
operations
.
isRunning
(
Operation
.
Sync
)
};
}
private
onModelChange
():
void
{
this
.
state
=
{
...
this
.
state
,
hasRemotes
:
this
.
model
.
remotes
.
length
>
0
,
HEAD
:
this
.
model
.
HEAD
hasRemotes
:
this
.
repository
.
remotes
.
length
>
0
,
HEAD
:
this
.
repository
.
HEAD
};
}
...
...
@@ -149,9 +149,9 @@ export class StatusBarCommands {
private
checkoutStatusBar
:
CheckoutStatusBar
;
private
disposables
:
Disposable
[]
=
[];
constructor
(
model
:
Repository
)
{
this
.
syncStatusBar
=
new
SyncStatusBar
(
model
);
this
.
checkoutStatusBar
=
new
CheckoutStatusBar
(
model
);
constructor
(
repository
:
Repository
)
{
this
.
syncStatusBar
=
new
SyncStatusBar
(
repository
);
this
.
checkoutStatusBar
=
new
CheckoutStatusBar
(
repository
);
}
get
onDidChange
():
Event
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录