Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6957a5c0
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 搜索 >>
提交
6957a5c0
编写于
7月 10, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make git activation async
fixes #50292
上级
b4ed5bdc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
66 deletion
+62
-66
extensions/git/src/api.ts
extensions/git/src/api.ts
+13
-8
extensions/git/src/main.ts
extensions/git/src/main.ts
+49
-58
未找到文件。
extensions/git/src/api.ts
浏览文件 @
6957a5c0
...
@@ -42,19 +42,24 @@ export interface API {
...
@@ -42,19 +42,24 @@ export interface API {
export
class
APIImpl
implements
API
{
export
class
APIImpl
implements
API
{
constructor
(
private
model
Promise
:
Promise
<
Model
>
)
{
}
constructor
(
private
model
:
Model
)
{
}
async
getGitPath
():
Promise
<
string
>
{
async
getGitPath
():
Promise
<
string
>
{
const
model
=
await
this
.
modelPromise
;
return
this
.
model
.
git
.
path
;
return
model
.
git
.
path
;
}
}
async
getRepositories
():
Promise
<
Repository
[]
>
{
async
getRepositories
():
Promise
<
Repository
[]
>
{
const
model
=
await
this
.
modelPromise
;
return
this
.
model
.
repositories
.
map
(
repository
=>
new
RepositoryImpl
(
repository
));
return
model
.
repositories
.
map
(
repository
=>
new
RepositoryImpl
(
repository
));
}
}
}
}
export
function
createApi
(
modelPromise
:
Promise
<
Model
>
):
API
{
export
class
NoopAPIImpl
implements
API
{
return
new
APIImpl
(
modelPromise
);
}
async
getGitPath
():
Promise
<
string
>
{
\ No newline at end of file
throw
new
Error
(
'
Git model not found
'
);
}
async
getRepositories
():
Promise
<
Repository
[]
>
{
throw
new
Error
(
'
Git model not found
'
);
}
}
extensions/git/src/main.ts
浏览文件 @
6957a5c0
...
@@ -16,12 +16,18 @@ import { GitDecorations } from './decorationProvider';
...
@@ -16,12 +16,18 @@ import { GitDecorations } from './decorationProvider';
import
{
Askpass
}
from
'
./askpass
'
;
import
{
Askpass
}
from
'
./askpass
'
;
import
{
toDisposable
,
filterEvent
,
eventToPromise
}
from
'
./util
'
;
import
{
toDisposable
,
filterEvent
,
eventToPromise
}
from
'
./util
'
;
import
TelemetryReporter
from
'
vscode-extension-telemetry
'
;
import
TelemetryReporter
from
'
vscode-extension-telemetry
'
;
import
{
API
,
createApi
}
from
'
./api
'
;
import
{
API
,
NoopAPIImpl
,
APIImpl
}
from
'
./api
'
;
import
{
GitProtocolHandler
}
from
'
./protocolHandler
'
;
import
{
GitProtocolHandler
}
from
'
./protocolHandler
'
;
let
telemetryReporter
:
TelemetryReporter
;
const
deactivateTasks
:
{
():
Promise
<
any
>
;
}[]
=
[]
;
async
function
init
(
context
:
ExtensionContext
,
outputChannel
:
OutputChannel
,
disposables
:
Disposable
[]):
Promise
<
Model
>
{
export
async
function
deactivate
():
Promise
<
any
>
{
for
(
const
task
of
deactivateTasks
)
{
await
task
();
}
}
async
function
createModel
(
context
:
ExtensionContext
,
outputChannel
:
OutputChannel
,
telemetryReporter
:
TelemetryReporter
,
disposables
:
Disposable
[]):
Promise
<
Model
>
{
const
pathHint
=
workspace
.
getConfiguration
(
'
git
'
).
get
<
string
>
(
'
path
'
);
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
info
=
await
findGit
(
pathHint
,
path
=>
outputChannel
.
appendLine
(
localize
(
'
looking
'
,
"
Looking for git in: {0}
"
,
path
)));
const
askpass
=
new
Askpass
();
const
askpass
=
new
Askpass
();
...
@@ -63,13 +69,32 @@ async function init(context: ExtensionContext, outputChannel: OutputChannel, dis
...
@@ -63,13 +69,32 @@ async function init(context: ExtensionContext, outputChannel: OutputChannel, dis
return
model
;
return
model
;
}
}
async
function
_activate
(
context
:
ExtensionContext
,
disposables
:
Disposable
[]):
Promise
<
Model
|
undefined
>
{
export
async
function
activate
(
context
:
ExtensionContext
):
Promise
<
API
>
{
const
disposables
:
Disposable
[]
=
[];
context
.
subscriptions
.
push
(
new
Disposable
(()
=>
Disposable
.
from
(...
disposables
).
dispose
()));
const
outputChannel
=
window
.
createOutputChannel
(
'
Git
'
);
const
outputChannel
=
window
.
createOutputChannel
(
'
Git
'
);
commands
.
registerCommand
(
'
git.showOutput
'
,
()
=>
outputChannel
.
show
());
commands
.
registerCommand
(
'
git.showOutput
'
,
()
=>
outputChannel
.
show
());
disposables
.
push
(
outputChannel
);
disposables
.
push
(
outputChannel
);
const
{
name
,
version
,
aiKey
}
=
require
(
context
.
asAbsolutePath
(
'
./package.json
'
))
as
{
name
:
string
,
version
:
string
,
aiKey
:
string
};
const
telemetryReporter
=
new
TelemetryReporter
(
name
,
version
,
aiKey
);
deactivateTasks
.
push
(()
=>
telemetryReporter
.
dispose
());
await
new
Promise
(
c
=>
setTimeout
(
c
,
10000
));
const
config
=
workspace
.
getConfiguration
(
'
git
'
,
null
);
const
enabled
=
config
.
get
<
boolean
>
(
'
enabled
'
);
if
(
!
enabled
)
{
const
onConfigChange
=
filterEvent
(
workspace
.
onDidChangeConfiguration
,
e
=>
e
.
affectsConfiguration
(
'
git
'
));
const
onEnabled
=
filterEvent
(
onConfigChange
,
()
=>
workspace
.
getConfiguration
(
'
git
'
,
null
).
get
<
boolean
>
(
'
enabled
'
)
===
true
);
await
eventToPromise
(
onEnabled
);
}
try
{
try
{
return
await
init
(
context
,
outputChannel
,
disposables
);
const
model
=
await
createModel
(
context
,
outputChannel
,
telemetryReporter
,
disposables
);
return
new
APIImpl
(
model
);
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
!
/Git installation not found/
.
test
(
err
.
message
||
''
))
{
if
(
!
/Git installation not found/
.
test
(
err
.
message
||
''
))
{
throw
err
;
throw
err
;
...
@@ -78,60 +103,30 @@ async function _activate(context: ExtensionContext, disposables: Disposable[]):
...
@@ -78,60 +103,30 @@ async function _activate(context: ExtensionContext, disposables: Disposable[]):
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
shouldIgnore
=
config
.
get
<
boolean
>
(
'
ignoreMissingGitWarning
'
)
===
true
;
const
shouldIgnore
=
config
.
get
<
boolean
>
(
'
ignoreMissingGitWarning
'
)
===
true
;
if
(
shouldIgnore
)
{
if
(
!
shouldIgnore
)
{
return
;
console
.
warn
(
err
.
message
);
outputChannel
.
appendLine
(
err
.
message
);
outputChannel
.
show
();
const
download
=
localize
(
'
downloadgit
'
,
"
Download Git
"
);
const
neverShowAgain
=
localize
(
'
neverShowAgain
'
,
"
Don't Show Again
"
);
const
choice
=
await
window
.
showWarningMessage
(
localize
(
'
notfound
'
,
"
Git not found. Install it or configure it using the 'git.path' setting.
"
),
download
,
neverShowAgain
);
if
(
choice
===
download
)
{
commands
.
executeCommand
(
'
vscode.open
'
,
Uri
.
parse
(
'
https://git-scm.com/
'
));
}
else
if
(
choice
===
neverShowAgain
)
{
await
config
.
update
(
'
ignoreMissingGitWarning
'
,
true
,
true
);
}
}
}
console
.
warn
(
err
.
message
);
return
new
NoopAPIImpl
();
outputChannel
.
appendLine
(
err
.
message
);
outputChannel
.
show
();
const
download
=
localize
(
'
downloadgit
'
,
"
Download Git
"
);
const
neverShowAgain
=
localize
(
'
neverShowAgain
'
,
"
Don't Show Again
"
);
const
choice
=
await
window
.
showWarningMessage
(
localize
(
'
notfound
'
,
"
Git not found. Install it or configure it using the 'git.path' setting.
"
),
download
,
neverShowAgain
);
if
(
choice
===
download
)
{
commands
.
executeCommand
(
'
vscode.open
'
,
Uri
.
parse
(
'
https://git-scm.com/
'
));
}
else
if
(
choice
===
neverShowAgain
)
{
await
config
.
update
(
'
ignoreMissingGitWarning
'
,
true
,
true
);
}
}
}
}
}
export
function
activate
(
context
:
ExtensionContext
):
API
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
,
null
);
const
enabled
=
config
.
get
<
boolean
>
(
'
enabled
'
);
const
disposables
:
Disposable
[]
=
[];
context
.
subscriptions
.
push
(
new
Disposable
(()
=>
Disposable
.
from
(...
disposables
).
dispose
()));
const
{
name
,
version
,
aiKey
}
=
require
(
context
.
asAbsolutePath
(
'
./package.json
'
))
as
{
name
:
string
,
version
:
string
,
aiKey
:
string
};
telemetryReporter
=
new
TelemetryReporter
(
name
,
version
,
aiKey
);
let
activatePromise
:
Promise
<
Model
|
undefined
>
;
if
(
enabled
)
{
activatePromise
=
_activate
(
context
,
disposables
);
}
else
{
const
onConfigChange
=
filterEvent
(
workspace
.
onDidChangeConfiguration
,
e
=>
e
.
affectsConfiguration
(
'
git
'
));
const
onEnabled
=
filterEvent
(
onConfigChange
,
()
=>
workspace
.
getConfiguration
(
'
git
'
,
null
).
get
<
boolean
>
(
'
enabled
'
)
===
true
);
activatePromise
=
eventToPromise
(
onEnabled
)
.
then
(()
=>
_activate
(
context
,
disposables
));
}
const
modelPromise
=
activatePromise
.
then
(
model
=>
model
||
Promise
.
reject
<
Model
>
(
'
Git model not found
'
));
activatePromise
.
catch
(
err
=>
console
.
error
(
err
));
return
createApi
(
modelPromise
);
}
async
function
checkGitVersion
(
info
:
IGit
):
Promise
<
void
>
{
async
function
checkGitVersion
(
info
:
IGit
):
Promise
<
void
>
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
shouldIgnore
=
config
.
get
<
boolean
>
(
'
ignoreLegacyWarning
'
)
===
true
;
const
shouldIgnore
=
config
.
get
<
boolean
>
(
'
ignoreLegacyWarning
'
)
===
true
;
...
@@ -159,7 +154,3 @@ async function checkGitVersion(info: IGit): Promise<void> {
...
@@ -159,7 +154,3 @@ async function checkGitVersion(info: IGit): Promise<void> {
await
config
.
update
(
'
ignoreLegacyWarning
'
,
true
,
true
);
await
config
.
update
(
'
ignoreLegacyWarning
'
,
true
,
true
);
}
}
}
}
export
function
deactivate
():
Promise
<
any
>
{
return
telemetryReporter
?
telemetryReporter
.
dispose
()
:
Promise
.
resolve
(
null
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录