Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
675ed02c
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,发现更多精彩内容 >>
提交
675ed02c
编写于
4月 17, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move RemoteSourceProvider to git api
上级
aeeec54c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
32 deletion
+38
-32
extensions/git/src/api/api1.ts
extensions/git/src/api/api1.ts
+5
-1
extensions/git/src/api/git.d.ts
extensions/git/src/api/git.d.ts
+14
-1
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+15
-15
extensions/git/src/model.ts
extensions/git/src/model.ts
+4
-15
未找到文件。
extensions/git/src/api/api1.ts
浏览文件 @
675ed02c
...
...
@@ -5,7 +5,7 @@
import
{
Model
}
from
'
../model
'
;
import
{
Repository
as
BaseRepository
,
Resource
}
from
'
../repository
'
;
import
{
InputBox
,
Git
,
API
,
Repository
,
Remote
,
RepositoryState
,
Branch
,
Ref
,
Submodule
,
Commit
,
Change
,
RepositoryUIState
,
Status
,
LogOptions
,
APIState
,
CommitOptions
,
GitExtension
,
RefType
}
from
'
./git
'
;
import
{
InputBox
,
Git
,
API
,
Repository
,
Remote
,
RepositoryState
,
Branch
,
Ref
,
Submodule
,
Commit
,
Change
,
RepositoryUIState
,
Status
,
LogOptions
,
APIState
,
CommitOptions
,
GitExtension
,
RefType
,
RemoteSourceProvider
}
from
'
./git
'
;
import
{
Event
,
SourceControlInputBox
,
Uri
,
SourceControl
,
Disposable
,
commands
}
from
'
vscode
'
;
import
{
mapEvent
}
from
'
../util
'
;
import
{
toGitUri
}
from
'
../uri
'
;
...
...
@@ -248,6 +248,10 @@ export class ApiImpl implements API {
return
result
?
new
ApiRepository
(
result
)
:
null
;
}
registerRemoteSourceProvider
(
provider
:
RemoteSourceProvider
):
Disposable
{
return
this
.
_model
.
registerRemoteSourceProvider
(
provider
);
}
constructor
(
private
_model
:
Model
)
{
}
}
...
...
extensions/git/src/api/git.d.ts
浏览文件 @
675ed02c
...
...
@@ -3,7 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Uri
,
SourceControlInputBox
,
Event
,
CancellationToken
}
from
'
vscode
'
;
import
{
Uri
,
Event
,
Disposable
,
ProviderResult
}
from
'
vscode
'
;
export
{
ProviderResult
}
from
'
vscode
'
;
export
interface
Git
{
readonly
path
:
string
;
...
...
@@ -189,6 +190,17 @@ export interface Repository {
commit
(
message
:
string
,
opts
?:
CommitOptions
):
Promise
<
void
>
;
}
export
interface
RemoteSource
{
readonly
name
:
string
;
readonly
url
:
string
;
}
export
interface
RemoteSourceProvider
{
readonly
name
:
string
;
readonly
supportsQuery
?:
boolean
;
getRemoteSources
(
query
?:
string
):
ProviderResult
<
RemoteSource
[]
>
;
}
export
type
APIState
=
'
uninitialized
'
|
'
initialized
'
;
export
interface
API
{
...
...
@@ -201,6 +213,7 @@ export interface API {
toGitUri
(
uri
:
Uri
,
ref
:
string
):
Uri
;
getRepository
(
uri
:
Uri
):
Repository
|
null
;
registerRemoteSourceProvider
(
provider
:
RemoteSourceProvider
):
Disposable
;
}
export
interface
GitExtension
{
...
...
extensions/git/src/commands.ts
浏览文件 @
675ed02c
...
...
@@ -9,9 +9,9 @@ import * as path from 'path';
import
{
commands
,
Disposable
,
LineChange
,
MessageOptions
,
OutputChannel
,
Position
,
ProgressLocation
,
QuickPickItem
,
Range
,
SourceControlResourceState
,
TextDocumentShowOptions
,
TextEditor
,
Uri
,
ViewColumn
,
window
,
workspace
,
WorkspaceEdit
,
WorkspaceFolder
,
TimelineItem
,
env
,
QuickPick
}
from
'
vscode
'
;
import
TelemetryReporter
from
'
vscode-extension-telemetry
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
Branch
,
GitErrorCodes
,
Ref
,
RefType
,
Status
,
CommitOptions
}
from
'
./api/git
'
;
import
{
Branch
,
GitErrorCodes
,
Ref
,
RefType
,
Status
,
CommitOptions
,
RemoteSourceProvider
,
RemoteSource
}
from
'
./api/git
'
;
import
{
ForcePushMode
,
Git
,
Stash
}
from
'
./git
'
;
import
{
Model
,
RemoteProvider
,
Remote
}
from
'
./model
'
;
import
{
Model
}
from
'
./model
'
;
import
{
Repository
,
Resource
,
ResourceGroupType
}
from
'
./repository
'
;
import
{
applyLineChanges
,
getModifiedRange
,
intersectDiffWithRange
,
invertLineChange
,
toLineRanges
}
from
'
./staging
'
;
import
{
fromGitUri
,
toGitUri
,
isGitUri
}
from
'
./uri
'
;
...
...
@@ -245,11 +245,11 @@ async function getQuickPickResult<T extends QuickPickItem>(quickpick: QuickPick<
return
result
;
}
class
RemoteProviderQuickPick
{
class
Remote
Source
ProviderQuickPick
{
private
quickpick
:
QuickPick
<
QuickPickItem
&
{
remote
?:
Remot
e
}
>
;
private
quickpick
:
QuickPick
<
QuickPickItem
&
{
remote
Source
?:
RemoteSourc
e
}
>
;
constructor
(
private
provider
:
RemoteProvider
)
{
constructor
(
private
provider
:
Remote
Source
Provider
)
{
this
.
quickpick
=
window
.
createQuickPick
();
this
.
quickpick
.
ignoreFocusOut
=
true
;
...
...
@@ -269,27 +269,27 @@ class RemoteProviderQuickPick {
@
throttle
async
query
():
Promise
<
void
>
{
this
.
quickpick
.
busy
=
true
;
const
remote
s
=
await
this
.
provider
.
getRemotes
(
this
.
quickpick
.
value
)
;
const
remote
Sources
=
await
this
.
provider
.
getRemoteSources
(
this
.
quickpick
.
value
)
||
[]
;
this
.
quickpick
.
busy
=
false
;
if
(
remotes
.
length
===
0
)
{
if
(
remote
Source
s
.
length
===
0
)
{
this
.
quickpick
.
items
=
[{
label
:
localize
(
'
none found
'
,
"
No remote repositories found.
"
),
alwaysShow
:
true
}];
}
else
{
this
.
quickpick
.
items
=
remote
s
.
map
(
remot
e
=>
({
label
:
remote
.
name
,
description
:
remote
.
url
,
remote
this
.
quickpick
.
items
=
remote
Sources
.
map
(
remoteSourc
e
=>
({
label
:
remote
Source
.
name
,
description
:
remote
Source
.
url
,
remote
:
remoteSource
}));
}
}
async
pick
():
Promise
<
Remote
|
undefined
>
{
async
pick
():
Promise
<
Remote
Source
|
undefined
>
{
this
.
query
();
const
result
=
await
getQuickPickResult
(
this
.
quickpick
);
return
result
?.
remote
;
return
result
?.
remote
Source
;
}
}
...
...
@@ -514,7 +514,7 @@ export class CommandCenter {
@
command
(
'
git.clone
'
)
async
clone
(
url
?:
string
,
parentPath
?:
string
):
Promise
<
void
>
{
if
(
!
url
)
{
const
quickpick
=
window
.
createQuickPick
<
(
QuickPickItem
&
{
provider
?:
RemoteProvider
})
>
();
const
quickpick
=
window
.
createQuickPick
<
(
QuickPickItem
&
{
provider
?:
Remote
Source
Provider
})
>
();
quickpick
.
ignoreFocusOut
=
true
;
const
providers
=
this
.
model
.
getRemoteProviders
()
...
...
@@ -544,7 +544,7 @@ export class CommandCenter {
if
(
result
)
{
if
(
result
.
provider
)
{
const
quickpick
=
new
RemoteProviderQuickPick
(
result
.
provider
);
const
quickpick
=
new
Remote
Source
ProviderQuickPick
(
result
.
provider
);
const
remote
=
await
quickpick
.
pick
();
url
=
remote
?.
url
;
}
else
{
...
...
extensions/git/src/model.ts
浏览文件 @
675ed02c
...
...
@@ -12,7 +12,7 @@ import * as path from 'path';
import
*
as
fs
from
'
fs
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
fromGitUri
}
from
'
./uri
'
;
import
{
GitErrorCodes
,
APIState
as
State
}
from
'
./api/git
'
;
import
{
GitErrorCodes
,
APIState
as
State
,
RemoteSourceProvider
}
from
'
./api/git
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -44,17 +44,6 @@ interface OpenRepository extends Disposable {
repository
:
Repository
;
}
export
interface
Remote
{
readonly
name
:
string
;
readonly
url
:
string
;
}
export
interface
RemoteProvider
{
readonly
name
:
string
;
readonly
supportsQuery
?:
boolean
;
getRemotes
(
query
?:
string
):
Remote
[]
|
Promise
<
Remote
[]
>
;
}
export
class
Model
{
private
_onDidOpenRepository
=
new
EventEmitter
<
Repository
>
();
...
...
@@ -85,7 +74,7 @@ export class Model {
this
.
_onDidChangeState
.
fire
(
state
);
}
private
remoteProviders
=
new
Set
<
RemoteProvider
>
();
private
remoteProviders
=
new
Set
<
Remote
Source
Provider
>
();
private
disposables
:
Disposable
[]
=
[];
...
...
@@ -460,12 +449,12 @@ export class Model {
return
undefined
;
}
registerRemote
Provider
(
provider
:
Remot
eProvider
):
Disposable
{
registerRemote
SourceProvider
(
provider
:
RemoteSourc
eProvider
):
Disposable
{
this
.
remoteProviders
.
add
(
provider
);
return
toDisposable
(()
=>
this
.
remoteProviders
.
delete
(
provider
));
}
getRemoteProviders
():
RemoteProvider
[]
{
getRemoteProviders
():
Remote
Source
Provider
[]
{
return
[...
this
.
remoteProviders
.
values
()];
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录