Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
997e9142
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,体验更适合开发者的 AI 搜索 >>
提交
997e9142
编写于
6月 20, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add diagnostic tool for git file event issues
上级
fb56f999
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
14 deletion
+52
-14
extensions/git/src/model.ts
extensions/git/src/model.ts
+1
-1
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+51
-13
未找到文件。
extensions/git/src/model.ts
浏览文件 @
997e9142
...
...
@@ -233,7 +233,7 @@ export class Model {
}
const
dotGit
=
await
this
.
git
.
getRepositoryDotGit
(
repositoryRoot
);
const
repository
=
new
Repository
(
this
.
git
.
open
(
repositoryRoot
,
dotGit
),
this
.
globalState
);
const
repository
=
new
Repository
(
this
.
git
.
open
(
repositoryRoot
,
dotGit
),
this
.
globalState
,
this
.
outputChannel
);
this
.
open
(
repository
);
}
catch
(
err
)
{
...
...
extensions/git/src/repository.ts
浏览文件 @
997e9142
...
...
@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
commands
,
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
SourceControlInputBoxValidation
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
DecorationData
,
Memento
,
SourceControlInputBoxValidationType
}
from
'
vscode
'
;
import
{
commands
,
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
SourceControlInputBoxValidation
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
DecorationData
,
Memento
,
SourceControlInputBoxValidationType
,
OutputChannel
,
LogLevel
,
env
}
from
'
vscode
'
;
import
{
Repository
as
BaseRepository
,
Commit
,
Stash
,
GitError
,
Submodule
,
CommitOptions
,
ForcePushMode
}
from
'
./git
'
;
import
{
anyEvent
,
filterEvent
,
eventToPromise
,
dispose
,
find
,
isDescendant
,
IDisposable
,
onceEvent
,
EmptyDisposable
,
debounceEvent
,
toDisposable
}
from
'
./util
'
;
import
{
anyEvent
,
filterEvent
,
eventToPromise
,
dispose
,
find
,
isDescendant
,
IDisposable
,
onceEvent
,
EmptyDisposable
,
debounceEvent
,
toDisposable
,
combinedDisposable
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
{
toGitUri
}
from
'
./uri
'
;
import
{
AutoFetcher
}
from
'
./autofetch
'
;
...
...
@@ -447,6 +447,39 @@ class ProgressManager {
}
}
class
FileEventLogger
{
private
eventDisposable
:
IDisposable
=
EmptyDisposable
;
private
logLevelDisposable
:
IDisposable
=
EmptyDisposable
;
constructor
(
private
onWorkspaceWorkingTreeFileChange
:
Event
<
Uri
>
,
private
onDotGitFileChange
:
Event
<
Uri
>
,
private
outputChannel
:
OutputChannel
)
{
this
.
logLevelDisposable
=
env
.
onDidChangeLogLevel
(
this
.
onDidChangeLogLevel
,
this
);
this
.
onDidChangeLogLevel
(
env
.
logLevel
);
}
private
onDidChangeLogLevel
(
level
:
LogLevel
):
void
{
this
.
eventDisposable
.
dispose
();
if
(
level
>
LogLevel
.
Debug
)
{
return
;
}
this
.
eventDisposable
=
combinedDisposable
([
this
.
onWorkspaceWorkingTreeFileChange
(
uri
=>
this
.
outputChannel
.
appendLine
(
`[debug] [wt] Change:
${
uri
.
fsPath
}
`
)),
this
.
onDotGitFileChange
(
uri
=>
this
.
outputChannel
.
appendLine
(
`[debug] [.git] Change:
${
uri
.
fsPath
}
`
))
]);
}
dispose
():
void
{
this
.
eventDisposable
.
dispose
();
this
.
logLevelDisposable
.
dispose
();
}
}
export
class
Repository
implements
Disposable
{
private
_onDidChangeRepository
=
new
EventEmitter
<
Uri
>
();
...
...
@@ -547,34 +580,39 @@ export class Repository implements Disposable {
private
isRepositoryHuge
=
false
;
private
didWarnAboutLimit
=
false
;
private
isFreshRepository
:
boolean
|
undefined
=
undefined
;
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
readonly
repository
:
BaseRepository
,
globalState
:
Memento
globalState
:
Memento
,
outputChannel
:
OutputChannel
)
{
const
workspaceWatcher
=
workspace
.
createFileSystemWatcher
(
'
**
'
);
this
.
disposables
.
push
(
workspaceWatcher
);
const
onWorkspaceFileChange
s
=
anyEvent
(
workspaceWatcher
.
onDidChange
,
workspaceWatcher
.
onDidCreate
,
workspaceWatcher
.
onDidDelete
);
const
onWorkspaceRepositoryFileChange
s
=
filterEvent
(
onWorkspaceFileChanges
,
uri
=>
isDescendant
(
repository
.
root
,
uri
.
fsPath
));
const
onWorkspaceWorkingTreeFileChange
s
=
filterEvent
(
onWorkspaceRepositoryFileChanges
,
uri
=>
!
/
\/\.
git
(
$|
\/)
/
.
test
(
uri
.
path
));
const
onWorkspaceFileChange
=
anyEvent
(
workspaceWatcher
.
onDidChange
,
workspaceWatcher
.
onDidCreate
,
workspaceWatcher
.
onDidDelete
);
const
onWorkspaceRepositoryFileChange
=
filterEvent
(
onWorkspaceFileChange
,
uri
=>
isDescendant
(
repository
.
root
,
uri
.
fsPath
));
const
onWorkspaceWorkingTreeFileChange
=
filterEvent
(
onWorkspaceRepositoryFileChange
,
uri
=>
!
/
\/\.
git
(
$|
\/)
/
.
test
(
uri
.
path
));
const
dotGitWatcher
=
fs
.
watch
(
repository
.
dotGit
);
const
on
RepositoryFil
eEmitter
=
new
EventEmitter
<
Uri
>
();
dotGitWatcher
.
on
(
'
change
'
,
(
_
,
e
)
=>
on
RepositoryFil
eEmitter
.
fire
(
Uri
.
file
(
path
.
join
(
repository
.
dotGit
,
e
as
string
))));
const
on
DotGitFileChang
eEmitter
=
new
EventEmitter
<
Uri
>
();
dotGitWatcher
.
on
(
'
change
'
,
(
_
,
e
)
=>
on
DotGitFileChang
eEmitter
.
fire
(
Uri
.
file
(
path
.
join
(
repository
.
dotGit
,
e
as
string
))));
dotGitWatcher
.
on
(
'
error
'
,
err
=>
console
.
error
(
err
));
this
.
disposables
.
push
(
toDisposable
(()
=>
dotGitWatcher
.
close
()));
const
on
RelevantRepositoryChanges
=
filterEvent
(
onRepositoryFil
eEmitter
.
event
,
uri
=>
!
/
\/\.
git
(\/
index
\.
lock
)?
$/
.
test
(
uri
.
path
));
const
on
DotGitFileChange
=
filterEvent
(
onDotGitFileChang
eEmitter
.
event
,
uri
=>
!
/
\/\.
git
(\/
index
\.
lock
)?
$/
.
test
(
uri
.
path
));
// FS changes should trigger `git status`:
// - any change inside the repository working tree
// - any change whithin the first level of the `.git` folder, except the folder itself and `index.lock`
const
onF
SChange
=
anyEvent
(
onWorkspaceWorkingTreeFileChanges
,
onRelevantRepositoryChanges
);
onF
SChange
(
this
.
onFS
Change
,
this
,
this
.
disposables
);
const
onF
ileChange
=
anyEvent
(
onWorkspaceWorkingTreeFileChange
,
onDotGitFileChange
);
onF
ileChange
(
this
.
onFile
Change
,
this
,
this
.
disposables
);
// Relevate repository changes should trigger virtual document change events
onRelevantRepositoryChanges
(
this
.
_onDidChangeRepository
.
fire
,
this
.
_onDidChangeRepository
,
this
.
disposables
);
onDotGitFileChange
(
this
.
_onDidChangeRepository
.
fire
,
this
.
_onDidChangeRepository
,
this
.
disposables
);
this
.
disposables
.
push
(
new
FileEventLogger
(
onWorkspaceWorkingTreeFileChange
,
onDotGitFileChange
,
outputChannel
));
const
root
=
Uri
.
file
(
repository
.
root
);
this
.
_sourceControl
=
scm
.
createSourceControl
(
'
git
'
,
'
Git
'
,
root
);
...
...
@@ -1454,7 +1492,7 @@ export class Repository implements Disposable {
return
result
;
}
private
onF
S
Change
(
_uri
:
Uri
):
void
{
private
onF
ile
Change
(
_uri
:
Uri
):
void
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
autorefresh
=
config
.
get
<
boolean
>
(
'
autorefresh
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录