Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
28d2b5d2
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,发现更多精彩内容 >>
提交
28d2b5d2
编写于
8月 24, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: git api
上级
811a6be0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
16 deletion
+102
-16
extensions/git/src/api/git.d.ts
extensions/git/src/api/git.d.ts
+47
-0
extensions/git/src/autofetch.ts
extensions/git/src/autofetch.ts
+1
-1
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+2
-2
extensions/git/src/contentProvider.ts
extensions/git/src/contentProvider.ts
+1
-1
extensions/git/src/git.ts
extensions/git/src/git.ts
+43
-8
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+8
-4
未找到文件。
extensions/git/src/api/git.d.ts
浏览文件 @
28d2b5d2
...
...
@@ -56,21 +56,68 @@ export interface Remote {
readonly
isReadOnly
:
boolean
;
}
export
interface
Change
{
// TODO
}
export
interface
RepositoryState
{
readonly
HEAD
:
Branch
|
undefined
;
readonly
refs
:
Ref
[];
readonly
remotes
:
Remote
[];
readonly
submodules
:
Submodule
[];
readonly
rebaseCommit
:
Commit
|
undefined
;
readonly
mergeChanges
:
Change
[];
readonly
indexChanges
:
Change
[];
readonly
workingTreeChanges
:
Change
[];
readonly
onDidChange
:
Event
<
void
>
;
}
export
const
enum
ConfigScope
{
System
,
Global
,
Local
}
export
interface
Repository
{
readonly
rootUri
:
Uri
;
readonly
inputBox
:
InputBox
;
readonly
state
:
RepositoryState
;
getConfigs
(
scope
:
ConfigScope
):
Promise
<
{
key
:
string
;
value
:
string
;
}[]
>
;
getConfig
(
scope
:
ConfigScope
,
key
:
string
):
Promise
<
string
>
;
setConfig
(
scope
:
ConfigScope
,
key
:
string
,
value
:
string
):
Promise
<
string
>
;
show
(
ref
:
string
,
path
:
string
):
Promise
<
string
>
;
getCommit
(
ref
:
string
):
Promise
<
Commit
>
;
getObjectDetails
(
treeish
:
string
,
path
:
string
):
Promise
<
{
mode
:
string
,
object
:
string
,
size
:
number
}
>
;
diffWithHEAD
(
path
:
string
):
Promise
<
string
>
;
diffWith
(
ref
:
string
,
path
:
string
):
Promise
<
string
>
;
diffIndexWithHEAD
(
path
:
string
):
Promise
<
string
>
;
diffIndexWith
(
ref
:
string
,
path
:
string
):
Promise
<
string
>
;
diffBlobs
(
object1
:
string
,
object2
:
string
):
Promise
<
string
>
;
diffBetween
(
ref1
:
string
,
ref2
:
string
,
path
:
string
):
Promise
<
string
>
;
hashObject
(
data
:
string
):
Promise
<
string
>
;
createBranch
(
name
:
string
,
checkout
:
boolean
,
ref
?:
string
):
Promise
<
void
>
;
deleteBranch
(
name
:
string
):
Promise
<
void
>
;
getBranch
(
name
:
string
):
Promise
<
Branch
>
;
setBranchUpstream
(
name
:
string
,
upstream
:
string
):
Promise
<
void
>
;
getMergeBase
(
ref1
:
string
,
ref2
:
string
):
Promise
<
string
>
;
status
():
Promise
<
void
>
;
checkout
(
treeish
:
string
):
Promise
<
void
>
;
addRemote
(
name
:
string
,
url
:
string
):
Promise
<
void
>
;
removeRemote
(
name
:
string
):
Promise
<
void
>
;
fetch
(
remote
?:
string
,
ref
?:
string
):
Promise
<
void
>
;
pull
():
Promise
<
void
>
;
}
export
interface
API
{
...
...
extensions/git/src/autofetch.ts
浏览文件 @
28d2b5d2
...
...
@@ -102,7 +102,7 @@ export class AutoFetcher {
}
try
{
await
this
.
repository
.
fetch
();
await
this
.
repository
.
fetch
Default
();
}
catch
(
err
)
{
if
(
err
.
gitErrorCode
===
GitErrorCodes
.
AuthenticationFailed
)
{
this
.
disable
();
...
...
extensions/git/src/commands.ts
浏览文件 @
28d2b5d2
...
...
@@ -1235,7 +1235,7 @@ export class CommandCenter {
}
const
name
=
result
.
replace
(
/^
\.
|
\/\.
|
\.\.
|~|
\^
|:|
\/
$|
\.
lock$|
\.
lock
\/
|
\\
|
\*
|
\s
|^
\s
*$|
\.
$/g
,
'
-
'
);
await
repository
.
branch
(
name
);
await
repository
.
branch
(
name
,
true
);
}
@
command
(
'
git.deleteBranch
'
,
{
repository
:
true
})
...
...
@@ -1355,7 +1355,7 @@ export class CommandCenter {
return
;
}
await
repository
.
fetch
();
await
repository
.
fetch
Default
();
}
@
command
(
'
git.pullFrom
'
,
{
repository
:
true
})
...
...
extensions/git/src/contentProvider.ts
浏览文件 @
28d2b5d2
...
...
@@ -92,7 +92,7 @@ export class GitContentProvider {
return
''
;
}
return
await
repository
.
diff
(
path
,
{
cached
:
ref
===
'
index
'
}
);
return
await
repository
.
diff
(
path
,
ref
===
'
index
'
);
}
const
repository
=
this
.
model
.
getRepository
(
uri
);
...
...
extensions/git/src/git.ts
浏览文件 @
28d2b5d2
...
...
@@ -654,10 +654,6 @@ export function parseLsFiles(raw: string): LsFilesElement[] {
.
map
(([,
mode
,
object
,
stage
,
file
])
=>
({
mode
,
object
,
stage
,
file
}));
}
export
interface
DiffOptions
{
cached
?:
boolean
;
}
export
class
Repository
{
constructor
(
...
...
@@ -828,10 +824,10 @@ export class Repository {
}
}
async
diff
(
path
:
string
,
options
:
DiffOptions
=
{}
):
Promise
<
string
>
{
async
diff
(
path
:
string
,
cached
=
false
):
Promise
<
string
>
{
const
args
=
[
'
diff
'
];
if
(
options
.
cached
)
{
if
(
cached
)
{
args
.
push
(
'
--cached
'
);
}
...
...
@@ -841,6 +837,20 @@ export class Repository {
return
result
.
stdout
;
}
async
diffBetween
(
ref1
:
string
,
ref2
:
string
,
path
:
string
):
Promise
<
string
>
{
const
args
=
[
'
diff
'
,
`
${
ref1
}
...
${
ref2
}
`
,
'
--
'
,
path
];
const
result
=
await
this
.
run
(
args
);
return
result
.
stdout
.
trim
();
}
async
getMergeBase
(
ref1
:
string
,
ref2
:
string
):
Promise
<
string
>
{
const
args
=
[
'
merge-base
'
,
ref1
,
ref2
];
const
result
=
await
this
.
run
(
args
);
return
result
.
stdout
.
trim
();
}
async
add
(
paths
:
string
[]):
Promise
<
void
>
{
const
args
=
[
'
add
'
,
'
-A
'
,
'
--
'
];
...
...
@@ -961,8 +971,13 @@ export class Repository {
throw
commitErr
;
}
async
branch
(
name
:
string
,
checkout
:
boolean
):
Promise
<
void
>
{
async
branch
(
name
:
string
,
checkout
:
boolean
,
ref
?:
string
):
Promise
<
void
>
{
const
args
=
checkout
?
[
'
checkout
'
,
'
-q
'
,
'
-b
'
,
name
]
:
[
'
branch
'
,
'
-q
'
,
name
];
if
(
ref
)
{
args
.
push
(
ref
);
}
await
this
.
run
(
args
);
}
...
...
@@ -976,6 +991,11 @@ export class Repository {
await
this
.
run
(
args
);
}
async
setBranchUpstream
(
name
:
string
,
upstream
:
string
):
Promise
<
void
>
{
const
args
=
[
'
branch
'
,
'
--set-upstream-to
'
,
upstream
,
name
];
await
this
.
run
(
args
);
}
async
deleteRef
(
ref
:
string
):
Promise
<
void
>
{
const
args
=
[
'
update-ref
'
,
'
-d
'
,
ref
];
await
this
.
run
(
args
);
...
...
@@ -1073,7 +1093,22 @@ export class Repository {
}
}
async
fetch
():
Promise
<
void
>
{
async
addRemote
(
name
:
string
,
url
:
string
):
Promise
<
void
>
{
const
args
=
[
'
remote
'
,
'
add
'
,
name
,
url
];
await
this
.
run
(
args
);
}
async
fetch
(
remote
?:
string
,
ref
?:
string
):
Promise
<
void
>
{
const
args
=
[
'
fetch
'
];
if
(
remote
)
{
args
.
push
(
remote
);
if
(
ref
)
{
args
.
push
(
ref
);
}
}
try
{
await
this
.
run
([
'
fetch
'
]);
}
catch
(
err
)
{
...
...
extensions/git/src/repository.ts
浏览文件 @
28d2b5d2
...
...
@@ -655,8 +655,8 @@ export class Repository implements Disposable {
await
this
.
run
(
Operation
.
Status
);
}
diff
(
path
:
string
,
options
:
DiffOptions
=
{}
):
Promise
<
string
>
{
return
this
.
run
(
Operation
.
Diff
,
()
=>
this
.
repository
.
diff
(
path
,
options
));
diff
(
path
:
string
,
cached
=
false
):
Promise
<
string
>
{
return
this
.
run
(
Operation
.
Diff
,
()
=>
this
.
repository
.
diff
(
path
,
cached
));
}
async
add
(
resources
:
Uri
[]):
Promise
<
void
>
{
...
...
@@ -746,7 +746,7 @@ export class Repository implements Disposable {
});
}
async
branch
(
name
:
string
):
Promise
<
void
>
{
async
branch
(
name
:
string
,
checkout
:
boolean
,
ref
?:
string
):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Branch
,
()
=>
this
.
repository
.
branch
(
name
,
true
));
}
...
...
@@ -783,7 +783,11 @@ export class Repository implements Disposable {
}
@
throttle
async
fetch
():
Promise
<
void
>
{
async
fetchDefault
():
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Fetch
,
()
=>
this
.
repository
.
fetch
());
}
async
fetch
(
remote
?:
string
,
ref
?:
string
):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Fetch
,
()
=>
this
.
repository
.
fetch
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录