Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ea831c19
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,发现更多精彩内容 >>
提交
ea831c19
编写于
12月 14, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #40156
上级
f1f2c196
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
37 deletion
+66
-37
extensions/git/src/decorationProvider.ts
extensions/git/src/decorationProvider.ts
+59
-35
extensions/git/src/git.ts
extensions/git/src/git.ts
+2
-1
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+5
-1
未找到文件。
extensions/git/src/decorationProvider.ts
浏览文件 @
ea831c19
...
...
@@ -10,18 +10,20 @@ import * as path from 'path';
import
{
Repository
,
GitResourceGroup
,
Status
}
from
'
./repository
'
;
import
{
Model
}
from
'
./model
'
;
import
{
debounce
}
from
'
./decorators
'
;
import
{
filterEvent
}
from
'
./util
'
;
import
{
Submodule
}
from
'
./git
'
;
import
{
filterEvent
,
dispose
}
from
'
./util
'
;
import
{
Submodule
,
GitErrorCodes
}
from
'
./git
'
;
type
Callback
=
{
resolve
:
(
status
:
boolean
)
=>
void
,
reject
:
(
err
:
any
)
=>
void
};
class
GitIgnoreDecorationProvider
implements
DecorationProvider
{
private
readonly
_onDidChangeDecorations
=
new
EventEmitter
<
Uri
[]
>
();
readonly
onDidChangeDecorations
:
Event
<
Uri
[]
>
=
this
.
_onDidChangeDecorations
.
event
;
private
checkIgnoreQueue
=
new
Map
<
string
,
{
resolve
:
(
status
:
boolean
)
=>
void
,
reject
:
(
err
:
any
)
=>
void
}
>
();
private
queue
=
new
Map
<
string
,
{
repository
:
Repository
;
queue
:
Map
<
string
,
Callback
>
;
}
>
();
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
repository
:
Repository
)
{
constructor
(
private
model
:
Model
)
{
this
.
disposables
.
push
(
window
.
registerDecorationProvider
(
this
),
filterEvent
(
workspace
.
onDidSaveTextDocument
,
e
=>
e
.
fileName
.
endsWith
(
'
.gitignore
'
))(
_
=>
this
.
_onDidChangeDecorations
.
fire
())
...
...
@@ -29,14 +31,22 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
);
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
this
.
checkIgnoreQueue
.
clear
();
}
provideDecoration
(
uri
:
Uri
):
Promise
<
DecorationData
|
undefined
>
{
const
repository
=
this
.
model
.
getRepository
(
uri
);
if
(
!
repository
)
{
return
Promise
.
resolve
(
undefined
);
}
let
queueItem
=
this
.
queue
.
get
(
repository
.
root
);
if
(
!
queueItem
)
{
queueItem
=
{
repository
,
queue
:
new
Map
<
string
,
Callback
>
()
};
this
.
queue
.
set
(
repository
.
root
,
queueItem
);
}
return
new
Promise
<
boolean
>
((
resolve
,
reject
)
=>
{
this
.
checkIgnoreQ
ueue
.
set
(
uri
.
fsPath
,
{
resolve
,
reject
});
queueItem
!
.
q
ueue
.
set
(
uri
.
fsPath
,
{
resolve
,
reject
});
this
.
checkIgnoreSoon
();
}).
then
(
ignored
=>
{
if
(
ignored
)
{
...
...
@@ -50,18 +60,31 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
@
debounce
(
500
)
private
checkIgnoreSoon
():
void
{
const
queue
=
new
Map
(
this
.
checkIgnoreQueue
.
entries
());
this
.
checkIgnoreQueue
.
clear
();
this
.
repository
.
checkIgnore
([...
queue
.
keys
()]).
then
(
ignoreSet
=>
{
for
(
const
[
key
,
value
]
of
queue
.
entries
())
{
value
.
resolve
(
ignoreSet
.
has
(
key
));
}
},
err
=>
{
console
.
error
(
err
);
for
(
const
[,
value
]
of
queue
.
entries
())
{
value
.
reject
(
err
);
}
});
const
queue
=
new
Map
(
this
.
queue
.
entries
());
this
.
queue
.
clear
();
for
(
const
[,
item
]
of
queue
)
{
const
paths
=
[...
item
.
queue
.
keys
()];
item
.
repository
.
checkIgnore
(
paths
).
then
(
ignoreSet
=>
{
for
(
const
[
key
,
value
]
of
item
.
queue
.
entries
())
{
value
.
resolve
(
ignoreSet
.
has
(
key
));
}
},
err
=>
{
if
(
err
.
gitErrorCode
!==
GitErrorCodes
.
IsInSubmodule
)
{
console
.
error
(
err
);
}
for
(
const
[,
value
]
of
item
.
queue
.
entries
())
{
value
.
reject
(
err
);
}
});
}
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
this
.
queue
.
clear
();
}
}
...
...
@@ -129,17 +152,21 @@ class GitDecorationProvider implements DecorationProvider {
export
class
GitDecorations
{
private
configListener
:
Disposable
;
private
model
Listener
:
Disposable
[]
=
[];
private
disposables
:
Disposable
[]
=
[]
;
private
model
Disposables
:
Disposable
[]
=
[];
private
providers
=
new
Map
<
Repository
,
Disposable
>
();
constructor
(
private
model
:
Model
)
{
this
.
configListener
=
workspace
.
onDidChangeConfiguration
(
e
=>
e
.
affectsConfiguration
(
'
git.decorations.enabled
'
)
&&
this
.
update
());
this
.
disposables
.
push
(
new
GitIgnoreDecorationProvider
(
model
));
const
onEnablementChange
=
filterEvent
(
workspace
.
onDidChangeConfiguration
,
e
=>
e
.
affectsConfiguration
(
'
git.decorations.enabled
'
));
onEnablementChange
(
this
.
update
,
this
,
this
.
disposables
);
this
.
update
();
}
private
update
():
void
{
const
enabled
=
workspace
.
getConfiguration
(
'
git
'
).
get
(
'
decorations.enabled
'
);
if
(
enabled
)
{
this
.
enable
();
}
else
{
...
...
@@ -148,26 +175,25 @@ export class GitDecorations {
}
private
enable
():
void
{
this
.
modelListener
=
[];
this
.
model
.
onDidOpenRepository
(
this
.
onDidOpenRepository
,
this
,
this
.
modelListener
);
this
.
model
.
onDidCloseRepository
(
this
.
onDidCloseRepository
,
this
,
this
.
modelListener
);
this
.
model
.
onDidOpenRepository
(
this
.
onDidOpenRepository
,
this
,
this
.
modelDisposables
);
this
.
model
.
onDidCloseRepository
(
this
.
onDidCloseRepository
,
this
,
this
.
modelDisposables
);
this
.
model
.
repositories
.
forEach
(
this
.
onDidOpenRepository
,
this
);
}
private
disable
():
void
{
this
.
model
Listener
.
forEach
(
d
=>
d
.
dispose
()
);
this
.
model
Disposables
=
dispose
(
this
.
modelDisposables
);
this
.
providers
.
forEach
(
value
=>
value
.
dispose
());
this
.
providers
.
clear
();
}
private
onDidOpenRepository
(
repository
:
Repository
):
void
{
const
provider
=
new
GitDecorationProvider
(
repository
);
const
ignoreProvider
=
new
GitIgnoreDecorationProvider
(
repository
);
this
.
providers
.
set
(
repository
,
Disposable
.
from
(
provider
,
ignoreProvider
));
this
.
providers
.
set
(
repository
,
provider
);
}
private
onDidCloseRepository
(
repository
:
Repository
):
void
{
const
provider
=
this
.
providers
.
get
(
repository
);
if
(
provider
)
{
provider
.
dispose
();
this
.
providers
.
delete
(
repository
);
...
...
@@ -175,9 +201,7 @@ export class GitDecorations {
}
dispose
():
void
{
this
.
configListener
.
dispose
();
this
.
modelListener
.
forEach
(
d
=>
d
.
dispose
());
this
.
providers
.
forEach
(
value
=>
value
.
dispose
);
this
.
providers
.
clear
();
this
.
disable
();
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
extensions/git/src/git.ts
浏览文件 @
ea831c19
...
...
@@ -318,7 +318,8 @@ export const GitErrorCodes = {
NoLocalChanges
:
'
NoLocalChanges
'
,
NoStashFound
:
'
NoStashFound
'
,
LocalChangesOverwritten
:
'
LocalChangesOverwritten
'
,
NoUpstreamBranch
:
'
NoUpstreamBranch
'
NoUpstreamBranch
:
'
NoUpstreamBranch
'
,
IsInSubmodule
:
'
IsInSubmodule
'
};
function
getGitErrorCode
(
stderr
:
string
):
string
|
undefined
{
...
...
extensions/git/src/repository.ts
浏览文件 @
ea831c19
...
...
@@ -834,7 +834,11 @@ export class Repository implements Disposable {
// paths are separated by the null-character
resolve
(
new
Set
<
string
>
(
data
.
split
(
'
\
0
'
)));
}
else
{
reject
(
new
GitError
({
stdout
:
data
,
stderr
,
exitCode
}));
if
(
/ is in submodule /
.
test
(
stderr
))
{
reject
(
new
GitError
({
stdout
:
data
,
stderr
,
exitCode
,
gitErrorCode
:
GitErrorCodes
.
IsInSubmodule
}));
}
else
{
reject
(
new
GitError
({
stdout
:
data
,
stderr
,
exitCode
}));
}
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录