Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9544e5fa
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 搜索 >>
提交
9544e5fa
编写于
11月 27, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git.enabled as a resource setting
fixes #37492
上级
e69ca9ff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
51 deletion
+32
-51
extensions/git/package.json
extensions/git/package.json
+1
-0
extensions/git/src/main.ts
extensions/git/src/main.ts
+0
-8
extensions/git/src/model.ts
extensions/git/src/model.ts
+31
-43
未找到文件。
extensions/git/package.json
浏览文件 @
9544e5fa
...
...
@@ -815,6 +815,7 @@
"properties"
:
{
"git.enabled"
:
{
"type"
:
"boolean"
,
"scope"
:
"resource"
,
"description"
:
"%config.enabled%"
,
"default"
:
true
},
...
...
extensions/git/src/main.ts
浏览文件 @
9544e5fa
...
...
@@ -22,8 +22,6 @@ async function init(context: ExtensionContext, outputChannel: OutputChannel, dis
const
telemetryReporter
:
TelemetryReporter
=
new
TelemetryReporter
(
name
,
version
,
aiKey
);
disposables
.
push
(
telemetryReporter
);
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
enabled
=
config
.
get
<
boolean
>
(
'
enabled
'
)
===
true
;
const
pathHint
=
workspace
.
getConfiguration
(
'
git
'
).
get
<
string
>
(
'
path
'
);
const
info
=
await
findGit
(
pathHint
,
path
=>
outputChannel
.
appendLine
(
localize
(
'
looking
'
,
"
Looking for git in: {0}
"
,
path
)));
const
askpass
=
new
Askpass
();
...
...
@@ -37,12 +35,6 @@ async function init(context: ExtensionContext, outputChannel: OutputChannel, dis
model
.
onDidCloseRepository
(
onRepository
,
null
,
disposables
);
onRepository
();
if
(
!
enabled
)
{
const
commandCenter
=
new
CommandCenter
(
git
,
model
,
outputChannel
,
telemetryReporter
);
disposables
.
push
(
commandCenter
);
return
;
}
outputChannel
.
appendLine
(
localize
(
'
using git
'
,
"
Using git {0} from {1}
"
,
info
.
version
,
info
.
path
));
const
onOutput
=
(
str
:
string
)
=>
outputChannel
.
append
(
str
);
...
...
extensions/git/src/model.ts
浏览文件 @
9544e5fa
...
...
@@ -5,10 +5,10 @@
'
use strict
'
;
import
{
workspace
,
WorkspaceFoldersChangeEvent
,
Uri
,
window
,
Event
,
EventEmitter
,
QuickPickItem
,
Disposable
,
SourceControl
,
SourceControlResourceGroup
,
TextEditor
,
Memento
}
from
'
vscode
'
;
import
{
workspace
,
WorkspaceFoldersChangeEvent
,
Uri
,
window
,
Event
,
EventEmitter
,
QuickPickItem
,
Disposable
,
SourceControl
,
SourceControlResourceGroup
,
TextEditor
,
Memento
,
ConfigurationChangeEvent
}
from
'
vscode
'
;
import
{
Repository
,
RepositoryState
}
from
'
./repository
'
;
import
{
memoize
,
sequentialize
,
debounce
}
from
'
./decorators
'
;
import
{
dispose
,
anyEvent
,
filterEvent
}
from
'
./util
'
;
import
{
dispose
,
anyEvent
,
filterEvent
,
IDisposable
}
from
'
./util
'
;
import
{
Git
,
GitErrorCodes
}
from
'
./git
'
;
import
*
as
path
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
...
...
@@ -67,45 +67,17 @@ export class Model {
private
possibleGitRepositoryPaths
=
new
Set
<
string
>
();
private
enabled
=
false
;
private
configurationChangeDisposable
:
Disposable
;
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
git
:
Git
,
private
globalState
:
Memento
)
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
this
.
enabled
=
config
.
get
<
boolean
>
(
'
enabled
'
)
===
true
;
this
.
configurationChangeDisposable
=
workspace
.
onDidChangeConfiguration
(
this
.
onDidChangeConfiguration
,
this
);
if
(
this
.
enabled
)
{
this
.
enable
();
}
}
private
onDidChangeConfiguration
():
void
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
enabled
=
config
.
get
<
boolean
>
(
'
enabled
'
)
===
true
;
if
(
enabled
===
this
.
enabled
)
{
return
;
}
this
.
enabled
=
enabled
;
if
(
enabled
)
{
this
.
enable
();
}
else
{
this
.
disable
();
}
}
private
enable
():
void
{
workspace
.
onDidChangeWorkspaceFolders
(
this
.
onDidChangeWorkspaceFolders
,
this
,
this
.
disposables
);
this
.
onDidChangeWorkspaceFolders
({
added
:
workspace
.
workspaceFolders
||
[],
removed
:
[]
});
window
.
onDidChangeVisibleTextEditors
(
this
.
onDidChangeVisibleTextEditors
,
this
,
this
.
disposables
);
this
.
onDidChangeVisibleTextEditors
(
window
.
visibleTextEditors
);
workspace
.
onDidChangeConfiguration
(
this
.
onDidChangeConfiguration
,
this
,
this
.
disposables
);
const
fsWatcher
=
workspace
.
createFileSystemWatcher
(
'
**
'
);
this
.
disposables
.
push
(
fsWatcher
);
...
...
@@ -117,15 +89,6 @@ export class Model {
this
.
scanWorkspaceFolders
();
}
private
disable
():
void
{
const
openRepositories
=
[...
this
.
openRepositories
];
openRepositories
.
forEach
(
r
=>
r
.
dispose
());
this
.
openRepositories
=
[];
this
.
possibleGitRepositoryPaths
.
clear
();
this
.
disposables
=
dispose
(
this
.
disposables
);
}
/**
* Scans the first level of each workspace folder, looking
* for git repositories.
...
...
@@ -175,6 +138,20 @@ export class Model {
openRepositoriesToDispose
.
forEach
(
r
=>
r
.
dispose
());
}
private
onDidChangeConfiguration
():
void
{
const
possibleRepositoryFolders
=
(
workspace
.
workspaceFolders
||
[])
.
filter
(
folder
=>
workspace
.
getConfiguration
(
'
git
'
,
folder
.
uri
).
get
<
boolean
>
(
'
enabled
'
)
===
true
)
.
filter
(
folder
=>
!
this
.
getOpenRepository
(
folder
.
uri
));
const
openRepositoriesToDispose
=
this
.
openRepositories
.
map
(
repository
=>
({
repository
,
root
:
Uri
.
file
(
repository
.
repository
.
root
)
}))
.
filter
(({
root
})
=>
workspace
.
getConfiguration
(
'
git
'
,
root
).
get
<
boolean
>
(
'
enabled
'
)
!==
true
)
.
map
(({
repository
})
=>
repository
);
possibleRepositoryFolders
.
forEach
(
p
=>
this
.
tryOpenRepository
(
p
.
uri
.
fsPath
));
openRepositoriesToDispose
.
forEach
(
r
=>
r
.
dispose
());
}
private
onDidChangeVisibleTextEditors
(
editors
:
TextEditor
[]):
void
{
editors
.
forEach
(
editor
=>
{
const
uri
=
editor
.
document
.
uri
;
...
...
@@ -199,6 +176,13 @@ export class Model {
return
;
}
const
config
=
workspace
.
getConfiguration
(
'
git
'
,
Uri
.
file
(
path
));
const
enabled
=
config
.
get
<
boolean
>
(
'
enabled
'
)
===
true
;
if
(
!
enabled
)
{
return
;
}
try
{
const
repositoryRoot
=
await
this
.
git
.
getRepositoryRoot
(
path
);
...
...
@@ -321,7 +305,11 @@ export class Model {
}
dispose
():
void
{
this
.
disable
();
this
.
configurationChangeDisposable
.
dispose
();
const
openRepositories
=
[...
this
.
openRepositories
];
openRepositories
.
forEach
(
r
=>
r
.
dispose
());
this
.
openRepositories
=
[];
this
.
possibleGitRepositoryPaths
.
clear
();
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录