Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3a2c97c5
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,发现更多精彩内容 >>
提交
3a2c97c5
编写于
1月 04, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor autostash behaviour
上级
5c8c42e8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
48 addition
and
58 deletion
+48
-58
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+48
-58
未找到文件。
extensions/git/src/repository.ts
浏览文件 @
3a2c97c5
...
...
@@ -546,11 +546,6 @@ export class Repository implements Disposable {
private
isFreshRepository
:
boolean
|
undefined
=
undefined
;
private
disposables
:
Disposable
[]
=
[];
private
_trackedCount
:
number
=
0
;
public
get
trackedCount
():
number
{
return
this
.
_trackedCount
;
}
constructor
(
private
readonly
repository
:
BaseRepository
,
globalState
:
Memento
...
...
@@ -944,26 +939,17 @@ export class Repository implements Disposable {
}
async
pullFrom
(
rebase
?:
boolean
,
remote
?:
string
,
branch
?:
string
):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Pull
,
async
()
=>
{
await
this
.
maybeAutoStash
(
async
()
=>
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
,
Uri
.
file
(
this
.
root
));
const
fetchOnPull
=
config
.
get
<
boolean
>
(
'
fetchOnPull
'
);
const
autoStash
=
config
.
get
<
boolean
>
(
'
autoStash
'
);
await
this
.
run
(
Operation
.
Pull
,
async
()
=>
{
const
doStash
=
autoStash
&&
this
.
trackedCount
>
0
;
if
(
doStash
)
{
await
this
.
repository
.
createStash
();
}
if
(
fetchOnPull
)
{
await
this
.
repository
.
pull
(
rebase
);
}
else
{
await
this
.
repository
.
pull
(
rebase
,
remote
,
branch
);
}
if
(
doStash
)
{
await
this
.
repository
.
popStash
();
}
});
});
}
...
...
@@ -1009,16 +995,10 @@ export class Repository implements Disposable {
pushBranch
=
`
${
head
.
name
}
:
${
head
.
upstream
.
name
}
`
;
}
await
this
.
run
(
Operation
.
Sync
,
async
()
=>
{
await
this
.
maybeAutoStash
(
async
()
=>
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
,
Uri
.
file
(
this
.
root
));
const
fetchOnPull
=
config
.
get
<
boolean
>
(
'
fetchOnPull
'
);
const
autoStash
=
config
.
get
<
boolean
>
(
'
autoStash
'
);
await
this
.
run
(
Operation
.
Sync
,
async
()
=>
{
const
doStash
=
autoStash
&&
this
.
trackedCount
>
0
;
if
(
doStash
)
{
await
this
.
repository
.
createStash
();
}
if
(
fetchOnPull
)
{
await
this
.
repository
.
pull
(
rebase
);
...
...
@@ -1026,10 +1006,6 @@ export class Repository implements Disposable {
await
this
.
repository
.
pull
(
rebase
,
remoteName
,
pullBranch
);
}
if
(
doStash
)
{
await
this
.
repository
.
popStash
();
}
const
remote
=
this
.
remotes
.
find
(
r
=>
r
.
name
===
remoteName
);
if
(
remote
&&
remote
.
isReadOnly
)
{
...
...
@@ -1042,6 +1018,7 @@ export class Repository implements Disposable {
await
this
.
repository
.
push
(
remoteName
,
pushBranch
);
}
});
});
}
async
show
(
ref
:
string
,
filePath
:
string
):
Promise
<
string
>
{
...
...
@@ -1354,20 +1331,17 @@ export class Repository implements Disposable {
this
.
indexGroup
.
resourceStates
=
index
;
this
.
workingTreeGroup
.
resourceStates
=
workingTree
;
let
totalCount
=
merge
.
length
+
index
.
length
+
workingTree
.
length
;
this
.
_trackedCount
=
totalCount
-
workingTree
.
filter
(
r
=>
r
.
type
===
Status
.
UNTRACKED
||
r
.
type
===
Status
.
IGNORED
).
length
;
// set count badge
const
countBadge
=
workspace
.
getConfiguration
(
'
git
'
).
get
<
string
>
(
'
countBadge
'
);
let
count
=
merge
.
length
+
index
.
length
+
workingTree
.
length
;
switch
(
countBadge
)
{
case
'
off
'
:
this
.
_sourceControl
.
count
=
0
;
break
;
case
'
all
'
:
this
.
_sourceControl
.
count
=
totalCount
;
break
;
case
'
tracked
'
:
this
.
_sourceControl
.
count
=
this
.
_trackedCount
;
break
;
case
'
off
'
:
count
=
0
;
break
;
case
'
tracked
'
:
count
=
count
-
workingTree
.
filter
(
r
=>
r
.
type
===
Status
.
UNTRACKED
||
r
.
type
===
Status
.
IGNORED
).
length
;
break
;
}
this
.
_sourceControl
.
count
=
count
;
// Disable `Discard All Changes` for "fresh" repositories
// https://github.com/Microsoft/vscode/issues/43066
const
isFreshRepository
=
!
this
.
_HEAD
||
!
this
.
_HEAD
.
commit
;
...
...
@@ -1400,6 +1374,22 @@ export class Repository implements Disposable {
}
}
private
async
maybeAutoStash
<
T
>
(
runOperation
:
()
=>
Promise
<
T
>
):
Promise
<
T
>
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
,
Uri
.
file
(
this
.
root
));
const
shouldAutoStash
=
config
.
get
<
boolean
>
(
'
autoStash
'
)
&&
this
.
workingTreeGroup
.
resourceStates
.
some
(
r
=>
r
.
type
!==
Status
.
UNTRACKED
&&
r
.
type
!==
Status
.
IGNORED
);
if
(
!
shouldAutoStash
)
{
return
await
runOperation
();
}
await
this
.
repository
.
createStash
(
undefined
,
true
);
const
result
=
await
runOperation
();
await
this
.
repository
.
popStash
();
return
result
;
}
private
onFSChange
(
_uri
:
Uri
):
void
{
const
config
=
workspace
.
getConfiguration
(
'
git
'
);
const
autorefresh
=
config
.
get
<
boolean
>
(
'
autorefresh
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录