Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bc9854b4
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,发现更多精彩内容 >>
提交
bc9854b4
编写于
4月 27, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: use environmentVariableCollection
上级
1f98bd6a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
80 addition
and
15 deletion
+80
-15
extensions/git/src/askpass.sh
extensions/git/src/askpass.sh
+2
-2
extensions/git/src/askpass.ts
extensions/git/src/askpass.ts
+2
-3
extensions/git/src/ipc/ipcServer.ts
extensions/git/src/ipc/ipcServer.ts
+24
-8
extensions/git/src/main.ts
extensions/git/src/main.ts
+9
-2
extensions/git/src/terminal.ts
extensions/git/src/terminal.ts
+43
-0
未找到文件。
extensions/git/src/askpass.sh
浏览文件 @
bc9854b4
#!/bin/sh
VSCODE_GIT_ASKPASS_PIPE
=
`
mktemp
`
VSCODE_GIT_ASKPASS_PIPE
=
"
$VSCODE_GIT_ASKPASS_PIPE
"
"
$VSCODE_GIT_ASKPASS_NODE
"
"
$VSCODE_GIT_ASKPASS_MAIN
"
$*
ELECTRON_RUN_AS_NODE
=
"1"
VSCODE_GIT_ASKPASS_PIPE
=
"
$VSCODE_GIT_ASKPASS_PIPE
"
"
$VSCODE_GIT_ASKPASS_NODE
"
"
$VSCODE_GIT_ASKPASS_MAIN
"
$*
cat
$VSCODE_GIT_ASKPASS_PIPE
rm
$VSCODE_GIT_ASKPASS_PIPE
\ No newline at end of file
rm
$VSCODE_GIT_ASKPASS_PIPE
extensions/git/src/askpass.ts
浏览文件 @
bc9854b4
...
...
@@ -15,9 +15,9 @@ export class Askpass implements IIPCHandler {
private
cache
=
new
Map
<
string
,
Credentials
>
();
private
credentialsProviders
=
new
Set
<
CredentialsProvider
>
();
static
async
create
(
outputChannel
:
OutputChannel
):
Promise
<
Askpass
>
{
static
async
create
(
outputChannel
:
OutputChannel
,
context
?:
string
):
Promise
<
Askpass
>
{
try
{
return
new
Askpass
(
await
createIPCServer
());
return
new
Askpass
(
await
createIPCServer
(
context
));
}
catch
(
err
)
{
outputChannel
.
appendLine
(
`[error] Failed to create git askpass IPC:
${
err
}
`
);
return
new
Askpass
();
...
...
@@ -74,7 +74,6 @@ export class Askpass implements IIPCHandler {
return
{
...
this
.
ipc
.
getEnv
(),
ELECTRON_RUN_AS_NODE
:
'
1
'
,
GIT_ASKPASS
:
path
.
join
(
__dirname
,
'
askpass.sh
'
),
VSCODE_GIT_ASKPASS_NODE
:
process
.
execPath
,
VSCODE_GIT_ASKPASS_MAIN
:
path
.
join
(
__dirname
,
'
askpass-main.js
'
)
...
...
extensions/git/src/ipc/ipcServer.ts
浏览文件 @
bc9854b4
...
...
@@ -11,27 +11,43 @@ import * as os from 'os';
import
*
as
fs
from
'
fs
'
;
import
*
as
crypto
from
'
crypto
'
;
function
getIPCHandlePath
(
nonce
:
string
):
string
{
function
getIPCHandlePath
(
id
:
string
):
string
{
if
(
process
.
platform
===
'
win32
'
)
{
return
`\\\\.\\pipe\\vscode-git-
ipc-
${
nonce
}
-sock`
;
return
`\\\\.\\pipe\\vscode-git-
${
id
}
-sock`
;
}
if
(
process
.
env
[
'
XDG_RUNTIME_DIR
'
])
{
return
path
.
join
(
process
.
env
[
'
XDG_RUNTIME_DIR
'
]
as
string
,
`vscode-git-
ipc-
${
nonce
}
.sock`
);
return
path
.
join
(
process
.
env
[
'
XDG_RUNTIME_DIR
'
]
as
string
,
`vscode-git-
${
id
}
.sock`
);
}
return
path
.
join
(
os
.
tmpdir
(),
`vscode-git-
ipc-
${
nonce
}
.sock`
);
return
path
.
join
(
os
.
tmpdir
(),
`vscode-git-
${
id
}
.sock`
);
}
export
interface
IIPCHandler
{
handle
(
request
:
any
):
Promise
<
any
>
;
}
export
async
function
createIPCServer
():
Promise
<
IIPCServer
>
{
export
async
function
createIPCServer
(
context
?:
string
):
Promise
<
IIPCServer
>
{
const
server
=
http
.
createServer
();
const
buffer
=
await
new
Promise
<
Buffer
>
((
c
,
e
)
=>
crypto
.
randomBytes
(
20
,
(
err
,
buf
)
=>
err
?
e
(
err
)
:
c
(
buf
)));
const
nonce
=
buffer
.
toString
(
'
hex
'
);
const
ipcHandlePath
=
getIPCHandlePath
(
nonce
);
const
hash
=
crypto
.
createHash
(
'
sha1
'
);
if
(
!
context
)
{
const
buffer
=
await
new
Promise
<
Buffer
>
((
c
,
e
)
=>
crypto
.
randomBytes
(
20
,
(
err
,
buf
)
=>
err
?
e
(
err
)
:
c
(
buf
)));
hash
.
update
(
buffer
);
}
else
{
hash
.
update
(
context
);
}
const
ipcHandlePath
=
getIPCHandlePath
(
hash
.
digest
(
'
hex
'
).
substr
(
0
,
10
));
if
(
process
.
platform
!==
'
win32
'
)
{
try
{
await
fs
.
promises
.
unlink
(
ipcHandlePath
);
}
catch
{
// noop
}
}
return
new
Promise
((
c
,
e
)
=>
{
try
{
...
...
extensions/git/src/main.ts
浏览文件 @
bc9854b4
...
...
@@ -36,11 +36,18 @@ async function createModel(context: ExtensionContext, outputChannel: OutputChann
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
=
await
Askpass
.
create
(
outputChannel
);
const
askpass
=
await
Askpass
.
create
(
outputChannel
,
context
.
storagePath
);
disposables
.
push
(
askpass
);
const
env
=
askpass
.
getEnv
();
for
(
const
name
of
Object
.
keys
(
env
))
{
context
.
environmentVariableCollection
.
replace
(
name
,
env
[
name
]);
}
context
.
subscriptions
.
push
(
askpass
.
registerCredentialsProvider
(
new
GitHubCredentialProvider
()));
const
git
=
new
Git
({
gitPath
:
info
.
path
,
version
:
info
.
version
,
env
:
askpass
.
getEnv
()
});
const
git
=
new
Git
({
gitPath
:
info
.
path
,
version
:
info
.
version
,
env
});
const
model
=
new
Model
(
git
,
askpass
,
context
.
globalState
,
outputChannel
);
disposables
.
push
(
model
);
...
...
extensions/git/src/terminal.ts
0 → 100644
浏览文件 @
bc9854b4
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ExtensionContext
,
workspace
}
from
'
vscode
'
;
import
{
filterEvent
,
IDisposable
}
from
'
./util
'
;
export
class
TerminalEnvironmentManager
{
private
readonly
disposable
:
IDisposable
;
private
_enabled
=
false
;
private
set
enabled
(
enabled
:
boolean
)
{
if
(
this
.
_enabled
===
enabled
)
{
return
;
}
this
.
_enabled
=
enabled
;
this
.
context
.
environmentVariableCollection
.
clear
();
if
(
enabled
)
{
for
(
const
name
of
Object
.
keys
(
this
.
env
))
{
this
.
context
.
environmentVariableCollection
.
replace
(
name
,
this
.
env
[
name
]);
}
}
}
constructor
(
private
readonly
context
:
ExtensionContext
,
private
readonly
env
:
{
[
key
:
string
]:
string
})
{
this
.
disposable
=
filterEvent
(
workspace
.
onDidChangeConfiguration
,
e
=>
e
.
affectsConfiguration
(
'
git
'
))
(
this
.
refresh
,
this
);
this
.
refresh
();
}
private
refresh
():
void
{
this
.
enabled
=
workspace
.
getConfiguration
(
'
git
'
,
null
).
get
(
'
terminalAuthentication
'
,
true
);
}
dispose
():
void
{
this
.
disposable
.
dispose
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录