Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4cd45c49
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,发现更多精彩内容 >>
提交
4cd45c49
编写于
6月 20, 2017
作者:
K
Krzysztof Cieślak
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Repository and Model changes
上级
1531c8d2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
4 deletion
+63
-4
extensions/git/src/git.ts
extensions/git/src/git.ts
+47
-1
extensions/git/src/model.ts
extensions/git/src/model.ts
+16
-3
未找到文件。
extensions/git/src/git.ts
浏览文件 @
4cd45c49
...
@@ -33,6 +33,11 @@ export interface Remote {
...
@@ -33,6 +33,11 @@ export interface Remote {
url
:
string
;
url
:
string
;
}
}
export
interface
Stash
{
id
:
string
;
description
:
string
;
}
export
enum
RefType
{
export
enum
RefType
{
Head
,
Head
,
RemoteHead
,
RemoteHead
,
...
@@ -277,7 +282,10 @@ export const GitErrorCodes = {
...
@@ -277,7 +282,10 @@ export const GitErrorCodes = {
RepositoryNotFound
:
'
RepositoryNotFound
'
,
RepositoryNotFound
:
'
RepositoryNotFound
'
,
RepositoryIsLocked
:
'
RepositoryIsLocked
'
,
RepositoryIsLocked
:
'
RepositoryIsLocked
'
,
BranchNotFullyMerged
:
'
BranchNotFullyMerged
'
,
BranchNotFullyMerged
:
'
BranchNotFullyMerged
'
,
NoRemoteReference
:
'
NoRemoteReference
'
NoRemoteReference
:
'
NoRemoteReference
'
,
NoLocalChanges
:
'
NoLocalChanges
'
,
NoStashFound
:
'
NoStashFound
'
,
LocalChangesOverwritten
:
'
LocalChangesOverwritten
'
};
};
function
getGitErrorCode
(
stderr
:
string
):
string
|
undefined
{
function
getGitErrorCode
(
stderr
:
string
):
string
|
undefined
{
...
@@ -834,6 +842,32 @@ export class Repository {
...
@@ -834,6 +842,32 @@ export class Repository {
}
}
}
}
async
stash
(
pop
:
boolean
=
false
,
index
?:
string
):
Promise
<
void
>
{
try
{
const
args
=
[
'
stash
'
];
if
(
pop
)
{
args
.
push
(
'
pop
'
);
if
(
index
)
{
args
.
push
(
`"stash{
${
index
}
}"`
);
}
}
await
this
.
run
(
args
);
}
catch
(
err
)
{
if
(
/No local changes to save/
.
test
(
err
.
stderr
||
''
))
{
err
.
gitErrorCode
=
GitErrorCodes
.
NoLocalChanges
;
}
else
if
(
/No stash found/
.
test
(
err
.
stderr
||
''
))
{
err
.
gitErrorCode
=
GitErrorCodes
.
NoStashFound
;
}
else
if
(
/error: Your local changes to the following files would be overwritten/
.
test
(
err
.
stderr
||
''
))
{
err
.
gitErrorCode
=
GitErrorCodes
.
LocalChangesOverwritten
;
}
throw
err
;
}
}
getStatus
(
limit
=
5000
):
Promise
<
{
status
:
IFileStatus
[];
didHitLimit
:
boolean
;
}
>
{
getStatus
(
limit
=
5000
):
Promise
<
{
status
:
IFileStatus
[];
didHitLimit
:
boolean
;
}
>
{
return
new
Promise
<
{
status
:
IFileStatus
[];
didHitLimit
:
boolean
;
}
>
((
c
,
e
)
=>
{
return
new
Promise
<
{
status
:
IFileStatus
[];
didHitLimit
:
boolean
;
}
>
((
c
,
e
)
=>
{
const
parser
=
new
GitStatusParser
();
const
parser
=
new
GitStatusParser
();
...
@@ -921,6 +955,18 @@ export class Repository {
...
@@ -921,6 +955,18 @@ export class Repository {
.
filter
(
ref
=>
!!
ref
)
as
Ref
[];
.
filter
(
ref
=>
!!
ref
)
as
Ref
[];
}
}
async
getStashes
():
Promise
<
Stash
[]
>
{
const
result
=
await
this
.
run
([
'
stash
'
,
'
list
'
]);
const
regex
=
/^stash@{
(\d
+
)
}:
(
.+
)
/
;
const
rawStashes
=
result
.
stdout
.
trim
().
split
(
'
\n
'
)
.
filter
(
b
=>
!!
b
)
.
map
(
line
=>
regex
.
exec
(
line
))
.
filter
(
g
=>
!!
g
)
.
map
((
groups
:
RegExpExecArray
)
=>
({
id
:
groups
[
1
],
description
:
groups
[
2
]
}));
return
uniqBy
(
rawStashes
,
remote
=>
remote
.
id
);
}
async
getRemotes
():
Promise
<
Remote
[]
>
{
async
getRemotes
():
Promise
<
Remote
[]
>
{
const
result
=
await
this
.
run
([
'
remote
'
,
'
--verbose
'
]);
const
result
=
await
this
.
run
([
'
remote
'
,
'
--verbose
'
]);
const
regex
=
/^
([^\s]
+
)\s
+
([^\s]
+
)\s
/
;
const
regex
=
/^
([^\s]
+
)\s
+
([^\s]
+
)\s
/
;
...
...
extensions/git/src/model.ts
浏览文件 @
4cd45c49
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
'
use strict
'
;
'
use strict
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
}
from
'
vscode
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
}
from
'
vscode
'
;
import
{
Git
,
Repository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
}
from
'
./git
'
;
import
{
Git
,
Repository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
,
Stash
}
from
'
./git
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
}
from
'
./util
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
*
as
path
from
'
path
'
;
import
*
as
path
from
'
path
'
;
...
@@ -215,7 +215,8 @@ export enum Operation {
...
@@ -215,7 +215,8 @@ export enum Operation {
DeleteBranch
=
1
<<
16
,
DeleteBranch
=
1
<<
16
,
Merge
=
1
<<
17
,
Merge
=
1
<<
17
,
Ignore
=
1
<<
18
,
Ignore
=
1
<<
18
,
Tag
=
1
<<
19
Tag
=
1
<<
19
,
Stash
=
1
<<
20
}
}
// function getOperationName(operation: Operation): string {
// function getOperationName(operation: Operation): string {
...
@@ -345,6 +346,11 @@ export class Model implements Disposable {
...
@@ -345,6 +346,11 @@ export class Model implements Disposable {
return
this
.
_remotes
;
return
this
.
_remotes
;
}
}
private
_stashes
:
Stash
[]
=
[];
get
stashes
():
Stash
[]
{
return
this
.
_stashes
;
}
private
_operations
=
new
OperationsImpl
();
private
_operations
=
new
OperationsImpl
();
get
operations
():
Operations
{
return
this
.
_operations
;
}
get
operations
():
Operations
{
return
this
.
_operations
;
}
...
@@ -359,6 +365,7 @@ export class Model implements Disposable {
...
@@ -359,6 +365,7 @@ export class Model implements Disposable {
this
.
_HEAD
=
undefined
;
this
.
_HEAD
=
undefined
;
this
.
_refs
=
[];
this
.
_refs
=
[];
this
.
_remotes
=
[];
this
.
_remotes
=
[];
this
.
_stashes
=
[];
this
.
_mergeGroup
=
new
MergeGroup
();
this
.
_mergeGroup
=
new
MergeGroup
();
this
.
_indexGroup
=
new
IndexGroup
();
this
.
_indexGroup
=
new
IndexGroup
();
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
();
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
();
...
@@ -542,6 +549,11 @@ export class Model implements Disposable {
...
@@ -542,6 +549,11 @@ export class Model implements Disposable {
});
});
}
}
@
throttle
async
stash
(
pop
:
boolean
=
false
,
index
?:
string
):
Promise
<
void
>
{
return
await
this
.
run
(
Operation
.
Stash
,
()
=>
this
.
repository
.
stash
(
pop
,
index
));
}
async
getCommitTemplate
():
Promise
<
string
>
{
async
getCommitTemplate
():
Promise
<
string
>
{
return
await
this
.
run
(
Operation
.
GetCommitTemplate
,
async
()
=>
this
.
repository
.
getCommitTemplate
());
return
await
this
.
run
(
Operation
.
GetCommitTemplate
,
async
()
=>
this
.
repository
.
getCommitTemplate
());
}
}
...
@@ -692,11 +704,12 @@ export class Model implements Disposable {
...
@@ -692,11 +704,12 @@ export class Model implements Disposable {
// noop
// noop
}
}
const
[
refs
,
remotes
]
=
await
Promise
.
all
([
this
.
repository
.
getRefs
(),
this
.
repository
.
getRemot
es
()]);
const
[
refs
,
remotes
,
stashes
]
=
await
Promise
.
all
([
this
.
repository
.
getRefs
(),
this
.
repository
.
getRemotes
(),
this
.
repository
.
getStash
es
()]);
this
.
_HEAD
=
HEAD
;
this
.
_HEAD
=
HEAD
;
this
.
_refs
=
refs
;
this
.
_refs
=
refs
;
this
.
_remotes
=
remotes
;
this
.
_remotes
=
remotes
;
this
.
_stashes
=
stashes
;
const
index
:
Resource
[]
=
[];
const
index
:
Resource
[]
=
[];
const
workingTree
:
Resource
[]
=
[];
const
workingTree
:
Resource
[]
=
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录