Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
daa8cce0
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,发现更多精彩内容 >>
提交
daa8cce0
编写于
1月 11, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: react to fs events
上级
29933d67
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
43 addition
and
20 deletion
+43
-20
extensions/git/src/main.ts
extensions/git/src/main.ts
+37
-1
extensions/git/src/model.ts
extensions/git/src/model.ts
+5
-18
extensions/git/src/scmProvider.ts
extensions/git/src/scmProvider.ts
+1
-1
未找到文件。
extensions/git/src/main.ts
浏览文件 @
daa8cce0
...
...
@@ -11,7 +11,9 @@ import { findGit, Git } from './git';
import
{
Model
}
from
'
./model
'
;
import
{
GitSCMProvider
}
from
'
./scmProvider
'
;
import
{
registerCommands
}
from
'
./commands
'
;
import
{
anyEvent
,
throttle
}
from
'
./util
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
decorate
,
debounce
}
from
'
core-decorators
'
;
nls
.
config
();
...
...
@@ -36,6 +38,37 @@ class TextDocumentContentProvider {
}
}
class
Watcher
{
private
disposables
:
Disposable
[];
constructor
(
private
model
:
Model
)
{
const
fsWatcher
=
workspace
.
createFileSystemWatcher
(
'
**
'
);
const
onFSChange
=
anyEvent
(
fsWatcher
.
onDidChange
,
fsWatcher
.
onDidCreate
,
fsWatcher
.
onDidDelete
);
this
.
disposables
=
[
fsWatcher
,
onFSChange
(
this
.
eventuallyUpdateModel
,
this
)
];
}
@
debounce
(
1000
)
private
eventuallyUpdateModel
():
void
{
this
.
updateModelAndWait
();
}
@
decorate
(
throttle
)
private
async
updateModelAndWait
():
Promise
<
void
>
{
console
.
log
(
'
UPDATE
'
);
await
this
.
model
.
update
();
await
new
Promise
(
c
=>
setTimeout
(
c
,
8000
));
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
}
}
async
function
init
(
disposables
:
Disposable
[]):
Promise
<
void
>
{
const
rootPath
=
workspace
.
rootPath
;
...
...
@@ -55,11 +88,14 @@ async function init(disposables: Disposable[]): Promise<void> {
outputChannel
.
appendLine
(
`Using git
${
info
.
version
}
from
${
info
.
path
}
`
);
git
.
onOutput
(
str
=>
outputChannel
.
append
(
str
),
null
,
disposables
);
const
watcher
=
new
Watcher
(
model
);
disposables
.
push
(
registerCommands
(
model
),
scm
.
registerSCMProvider
(
'
git
'
,
provider
),
workspace
.
registerTextDocumentContentProvider
(
'
git-index
'
,
new
TextDocumentContentProvider
(
git
,
rootPath
)),
outputChannel
outputChannel
,
watcher
);
}
...
...
extensions/git/src/model.ts
浏览文件 @
daa8cce0
...
...
@@ -203,21 +203,8 @@ export class Model {
return
this
.
_remotes
;
}
update
(
now
=
false
):
void
{
if
(
now
)
{
this
.
updateNow
();
}
else
{
this
.
eventuallyUpdate
();
}
}
@
debounce
(
500
)
private
eventuallyUpdate
():
void
{
this
.
updateNow
();
}
@
decorate
(
throttle
)
private
async
updateNow
():
Promise
<
void
>
{
async
update
():
Promise
<
void
>
{
const
status
=
await
this
.
repository
.
getStatus
();
let
HEAD
:
IRef
|
undefined
;
...
...
@@ -286,13 +273,13 @@ export class Model {
async
stage
(...
resources
:
Resource
[]):
Promise
<
void
>
{
const
paths
=
resources
.
map
(
r
=>
r
.
uri
.
fsPath
);
await
this
.
repository
.
add
(
paths
);
await
this
.
update
Now
();
await
this
.
update
();
}
async
unstage
(...
resources
:
Resource
[]):
Promise
<
void
>
{
const
paths
=
resources
.
map
(
r
=>
r
.
uri
.
fsPath
);
await
this
.
repository
.
revertFiles
(
'
HEAD
'
,
paths
);
await
this
.
update
Now
();
await
this
.
update
();
}
async
commit
(
message
:
string
,
opts
:
{
all
?:
boolean
,
amend
?:
boolean
,
signoff
?:
boolean
}
=
Object
.
create
(
null
)):
Promise
<
void
>
{
...
...
@@ -301,7 +288,7 @@ export class Model {
}
await
this
.
repository
.
commit
(
message
,
opts
);
await
this
.
update
Now
();
await
this
.
update
();
}
async
clean
(...
resources
:
Resource
[]):
Promise
<
void
>
{
...
...
@@ -332,6 +319,6 @@ export class Model {
}
await
Promise
.
all
(
promises
);
await
this
.
update
Now
();
await
this
.
update
();
}
}
\ No newline at end of file
extensions/git/src/scmProvider.ts
浏览文件 @
daa8cce0
...
...
@@ -18,7 +18,7 @@ export class GitSCMProvider implements SCMProvider {
get
label
():
string
{
return
'
Git
'
;
}
constructor
(
private
model
:
Model
)
{
model
.
update
(
true
);
model
.
update
();
}
commit
(
message
:
string
):
Thenable
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录