Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
78d61d55
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78d61d55
编写于
8月 22, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: use simpler versioning scheme
上级
f9982d29
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
114 deletion
+23
-114
extensions/git/package.json
extensions/git/package.json
+0
-1
extensions/git/src/api/api.ts
extensions/git/src/api/api.ts
+0
-55
extensions/git/src/api/api1.ts
extensions/git/src/api/api1.ts
+1
-12
extensions/git/src/api/extension.ts
extensions/git/src/api/extension.ts
+19
-4
extensions/git/src/api/git.d.ts
extensions/git/src/api/git.d.ts
+3
-36
extensions/git/src/main.ts
extensions/git/src/main.ts
+0
-2
extensions/git/yarn.lock
extensions/git/yarn.lock
+0
-4
未找到文件。
extensions/git/package.json
浏览文件 @
78d61d55
...
...
@@ -1197,7 +1197,6 @@
"file-type"
:
"^7.2.0"
,
"iconv-lite"
:
"0.4.19"
,
"jschardet"
:
"^1.6.0"
,
"semver"
:
"^5.5.1"
,
"vscode-extension-telemetry"
:
"0.0.18"
,
"vscode-nls"
:
"^3.2.4"
,
"which"
:
"^1.3.0"
...
...
extensions/git/src/api/api.ts
已删除
100644 → 0
浏览文件 @
f9982d29
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Model
}
from
'
../model
'
;
import
{
API
}
from
'
./git
'
;
import
*
as
semver
from
'
semver
'
;
interface
ApiCtor
{
new
(
model
:
Model
):
API
;
}
const
versions
:
string
[]
=
[];
const
apis
=
new
Map
<
string
,
ApiCtor
>
();
export
function
getAPI
(
model
:
Model
,
range
:
string
):
API
{
if
(
!
range
)
{
throw
new
Error
(
`Please provide a Git extension API version range. Available versions: [
${
versions
.
join
(
'
,
'
)}
]`
);
}
const
version
=
semver
.
maxSatisfying
(
versions
,
range
);
if
(
!
version
)
{
throw
new
Error
(
`There's no available Git extension API for the given range: '
${
range
}
'. Available versions: [
${
versions
.
join
(
'
,
'
)}
]`
);
}
const
api
=
apis
.
get
(
version
)
!
;
return
new
api
(
model
);
}
export
function
Api
(
version
:
string
):
Function
{
return
function
(
ctor
:
ApiCtor
)
{
if
(
apis
.
has
(
version
))
{
throw
new
Error
(
`Git extension API version
${
version
}
already registered.`
);
}
versions
.
push
(
version
);
apis
.
set
(
version
,
ctor
);
};
}
export
function
deprecated
(
target
:
any
,
key
:
string
,
descriptor
:
any
):
void
{
if
(
typeof
descriptor
.
value
!==
'
function
'
)
{
throw
new
Error
(
'
not supported
'
);
}
const
fn
=
descriptor
.
value
;
descriptor
.
value
=
function
()
{
console
.
warn
(
`Git extension API method '
${
key
}
' is deprecated.`
);
return
fn
.
apply
(
this
,
arguments
);
};
}
\ No newline at end of file
extensions/git/src/api/api1.ts
浏览文件 @
78d61d55
...
...
@@ -7,11 +7,9 @@
import
{
Model
}
from
'
../model
'
;
import
{
Repository
as
BaseRepository
}
from
'
../repository
'
;
import
{
InputBox
,
ExecResult
,
SpawnOptions
,
Git
,
API
,
Repository
}
from
'
./git
'
;
import
{
Api
}
from
'
./api
'
;
import
{
InputBox
,
Git
,
API
,
Repository
}
from
'
./git
'
;
import
{
Event
,
SourceControlInputBox
,
Uri
}
from
'
vscode
'
;
import
{
mapEvent
}
from
'
../util
'
;
import
*
as
cp
from
'
child_process
'
;
class
ApiInputBox
implements
InputBox
{
set
value
(
value
:
string
)
{
this
.
_inputBox
.
value
=
value
;
}
...
...
@@ -35,17 +33,8 @@ export class ApiGit implements Git {
get
path
():
string
{
return
this
.
_model
.
git
.
path
;
}
constructor
(
private
_model
:
Model
)
{
}
exec
(
args
:
string
[],
options
:
SpawnOptions
):
Promise
<
ExecResult
<
string
>>
{
return
this
.
_model
.
git
.
exec2
(
args
,
options
);
}
spawn
(
args
:
string
[],
options
:
SpawnOptions
):
cp
.
ChildProcess
{
return
this
.
_model
.
git
.
spawn
(
args
,
options
);
}
}
@
Api
(
'
1.0.0
'
)
export
class
ApiImpl
implements
API
{
readonly
git
=
new
ApiGit
(
this
.
_model
);
...
...
extensions/git/src/api/extension.ts
浏览文件 @
78d61d55
...
...
@@ -7,8 +7,19 @@
import
{
Model
}
from
'
../model
'
;
import
{
GitExtension
,
Repository
,
API
}
from
'
./git
'
;
import
{
getAPI
,
deprecated
}
from
'
./api
'
;
import
{
ApiRepository
}
from
'
./api1
'
;
import
{
ApiRepository
,
ApiImpl
}
from
'
./api1
'
;
export
function
deprecated
(
target
:
any
,
key
:
string
,
descriptor
:
any
):
void
{
if
(
typeof
descriptor
.
value
!==
'
function
'
)
{
throw
new
Error
(
'
not supported
'
);
}
const
fn
=
descriptor
.
value
;
descriptor
.
value
=
function
()
{
console
.
warn
(
`Git extension API method '
${
key
}
' is deprecated.`
);
return
fn
.
apply
(
this
,
arguments
);
};
}
class
NoModelGitExtension
implements
GitExtension
{
...
...
@@ -41,8 +52,12 @@ class GitExtensionImpl implements GitExtension {
return
this
.
_model
.
repositories
.
map
(
repository
=>
new
ApiRepository
(
repository
));
}
getAPI
(
range
:
string
):
API
{
return
getAPI
(
this
.
_model
,
range
);
getAPI
(
version
:
number
):
API
{
if
(
version
!==
1
)
{
throw
new
Error
(
`No API version
${
version
}
found.`
);
}
return
new
ApiImpl
(
this
.
_model
);
}
}
...
...
extensions/git/src/api/git.d.ts
浏览文件 @
78d61d55
...
...
@@ -6,24 +6,8 @@
import
{
Uri
,
SourceControlInputBox
,
Event
,
CancellationToken
}
from
'
vscode
'
;
import
*
as
cp
from
'
child_process
'
;
export
interface
ExecResult
<
T
extends
string
|
Buffer
>
{
readonly
exitCode
:
number
;
readonly
stdout
:
T
;
readonly
stderr
:
string
;
}
export
interface
SpawnOptions
extends
cp
.
SpawnOptions
{
readonly
cwd
:
string
;
readonly
input
?:
string
;
readonly
encoding
?:
string
;
readonly
log
?:
boolean
;
readonly
cancellationToken
?:
CancellationToken
;
}
export
interface
Git
{
readonly
path
:
string
;
exec
(
args
:
string
[],
options
:
SpawnOptions
):
Promise
<
ExecResult
<
string
>>
;
spawn
(
args
:
string
[],
options
:
SpawnOptions
):
cp
.
ChildProcess
;
}
export
interface
API
{
...
...
@@ -42,30 +26,13 @@ export interface Repository {
readonly
inputBox
:
InputBox
;
}
declare
module
GitExtension
{
}
export
interface
GitExtension
{
/**
* Returns the latest available API compatible with the
* provided version range.
* Returns a specific API version.
*
* @param
range Semver version range for API compatibility
.
* @param
version Version number
.
* @returns API instance
*/
getAPI
(
range
:
string
):
API
;
/**
* Returns the collection of active repositories.
*
* @deprecated Use `API.repositories` instead.
*/
getRepositories
():
Promise
<
Repository
[]
>
;
/**
* Returns the path to the current git executable.
*
* @deprecated Use `API.gitPath` instead.
*/
getGitPath
():
Promise
<
string
>
;
getAPI
(
version
:
1
):
API
;
}
\ No newline at end of file
extensions/git/src/main.ts
浏览文件 @
78d61d55
...
...
@@ -21,8 +21,6 @@ import { GitExtension } from './api/git';
import
{
GitProtocolHandler
}
from
'
./protocolHandler
'
;
import
{
createGitExtension
}
from
'
./api/extension
'
;
import
'
./api/api1
'
;
const
deactivateTasks
:
{
():
Promise
<
any
>
;
}[]
=
[];
export
async
function
deactivate
():
Promise
<
any
>
{
...
...
extensions/git/yarn.lock
浏览文件 @
78d61d55
...
...
@@ -251,10 +251,6 @@ semver@^5.3.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
semver@^5.5.1:
version "5.5.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477"
supports-color@3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录