Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2e6c8db7
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,发现更多精彩内容 >>
提交
2e6c8db7
编写于
1月 10, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: clean commands
上级
cbb7a2cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
13 deletion
+64
-13
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+28
-8
extensions/git/src/model.ts
extensions/git/src/model.ts
+36
-5
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
2e6c8db7
...
...
@@ -5,9 +5,10 @@
'
use strict
'
;
import
{
Uri
,
commands
,
scm
,
Disposable
,
SCMResourceGroup
,
SCMResource
}
from
'
vscode
'
;
import
{
Model
,
Resource
,
ResourceGroup
}
from
'
./model
'
;
import
{
Uri
,
commands
,
scm
,
Disposable
,
SCMResourceGroup
,
SCMResource
,
window
}
from
'
vscode
'
;
import
{
Model
,
Resource
}
from
'
./model
'
;
import
{
log
}
from
'
./util
'
;
import
*
as
path
from
'
path
'
;
type
Command
=
(...
args
:
any
[])
=>
any
;
...
...
@@ -39,12 +40,31 @@ async function unstageAll(model: Model): Promise<void> {
return
await
model
.
unstage
();
}
function
clean
(
model
:
Model
,
resource
:
Resource
):
void
{
log
(
'
clean
'
,
resource
);
async
function
clean
(
model
:
Model
,
resource
:
Resource
):
Promise
<
void
>
{
const
basename
=
path
.
basename
(
resource
.
uri
.
fsPath
);
const
message
=
`Are you sure you want to clean changes in
${
basename
}
?`
;
const
yes
=
'
Yes
'
;
const
no
=
'
No, keep them
'
;
const
pick
=
await
window
.
showQuickPick
([
no
,
yes
],
{
placeHolder
:
message
});
if
(
pick
!==
yes
)
{
return
;
}
return
await
model
.
clean
(
resource
);
}
function
cleanAll
(
model
:
Model
,
resourceGroup
:
ResourceGroup
):
void
{
log
(
'
clean all
'
,
resourceGroup
);
async
function
cleanAll
(
model
:
Model
):
Promise
<
void
>
{
const
message
=
`Are you sure you want to clean all changes?`
;
const
yes
=
'
Yes
'
;
const
no
=
'
No, keep them
'
;
const
pick
=
await
window
.
showQuickPick
([
no
,
yes
],
{
placeHolder
:
message
});
if
(
pick
!==
yes
)
{
return
;
}
return
await
model
.
clean
(...
model
.
workingTreeGroup
.
resources
);
}
function
resolveURI
<
R
>
(
command
:
(
t
:
SCMResource
|
SCMResourceGroup
|
undefined
)
=>
R
):
(
uri
:
Uri
)
=>
R
|
undefined
{
...
...
@@ -83,8 +103,8 @@ export function registerCommands(model: Model): Disposable {
commands
.
registerCommand
(
'
git.stageAll
'
,
compose
(
stageAll
,
catchErrors
,
bindModel
)),
commands
.
registerCommand
(
'
git.unstage
'
,
compose
(
unstage
,
catchErrors
,
bindModel
,
resolveURI
)),
commands
.
registerCommand
(
'
git.unstageAll
'
,
compose
(
unstageAll
,
catchErrors
,
bindModel
)),
commands
.
registerCommand
(
'
git.clean
'
,
compose
(
clean
,
bindModel
,
resolveURI
)),
commands
.
registerCommand
(
'
git.cleanAll
'
,
compose
(
cleanAll
,
bindModel
,
resolveURI
)),
commands
.
registerCommand
(
'
git.clean
'
,
compose
(
clean
,
catchErrors
,
bindModel
,
resolveURI
)),
commands
.
registerCommand
(
'
git.cleanAll
'
,
compose
(
cleanAll
,
catchErrors
,
bindModel
)),
];
return
Disposable
.
from
(...
disposables
);
...
...
extensions/git/src/model.ts
浏览文件 @
2e6c8db7
...
...
@@ -116,9 +116,9 @@ export class ResourceGroup implements SCMResourceGroup {
get
id
():
string
{
return
this
.
_id
;
}
get
label
():
string
{
return
this
.
_label
;
}
get
resources
():
SCM
Resource
[]
{
return
this
.
_resources
;
}
get
resources
():
Resource
[]
{
return
this
.
_resources
;
}
constructor
(
private
_id
:
string
,
private
_label
:
string
,
private
_resources
:
SCM
Resource
[])
{
constructor
(
private
_id
:
string
,
private
_label
:
string
,
private
_resources
:
Resource
[])
{
}
}
...
...
@@ -127,7 +127,7 @@ export class MergeGroup extends ResourceGroup {
static
readonly
ID
=
'
merge
'
;
constructor
(
resources
:
SCM
Resource
[])
{
constructor
(
resources
:
Resource
[])
{
super
(
MergeGroup
.
ID
,
'
Merge Changes
'
,
resources
);
}
}
...
...
@@ -136,7 +136,7 @@ export class IndexGroup extends ResourceGroup {
static
readonly
ID
=
'
index
'
;
constructor
(
resources
:
SCM
Resource
[])
{
constructor
(
resources
:
Resource
[])
{
super
(
IndexGroup
.
ID
,
'
Staged Changes
'
,
resources
);
}
}
...
...
@@ -145,7 +145,7 @@ export class WorkingTreeGroup extends ResourceGroup {
static
readonly
ID
=
'
workingTree
'
;
constructor
(
resources
:
SCM
Resource
[])
{
constructor
(
resources
:
Resource
[])
{
super
(
WorkingTreeGroup
.
ID
,
'
Changes
'
,
resources
);
}
}
...
...
@@ -299,4 +299,35 @@ export class Model {
await
this
.
repository
.
commit
(
message
,
opts
);
await
this
.
updateNow
();
}
async
clean
(...
resources
:
Resource
[]):
Promise
<
void
>
{
const
toClean
:
string
[]
=
[];
const
toCheckout
:
string
[]
=
[];
resources
.
forEach
(
r
=>
{
switch
(
r
.
type
)
{
case
Status
.
UNTRACKED
:
case
Status
.
IGNORED
:
toClean
.
push
(
r
.
uri
.
fsPath
);
break
;
default
:
toCheckout
.
push
(
r
.
uri
.
fsPath
);
break
;
}
});
const
promises
:
Promise
<
void
>
[]
=
[];
if
(
toClean
.
length
>
0
)
{
promises
.
push
(
this
.
repository
.
clean
(
toClean
));
}
if
(
toCheckout
.
length
>
0
)
{
promises
.
push
(
this
.
repository
.
checkout
(
''
,
toCheckout
));
}
await
Promise
.
all
(
promises
);
await
this
.
updateNow
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录