Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b348a0b7
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,发现更多精彩内容 >>
提交
b348a0b7
编写于
5月 06, 2017
作者:
M
Maik Riechert
提交者:
Dirk Baeumer
5月 26, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle git branch delete error ("not fully merged")
上级
b96478eb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
27 deletion
+45
-27
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+37
-22
extensions/git/src/git.ts
extensions/git/src/git.ts
+6
-3
extensions/git/src/model.ts
extensions/git/src/model.ts
+2
-2
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
b348a0b7
...
...
@@ -62,21 +62,18 @@ class CheckoutRemoteHeadItem extends CheckoutItem {
class
BranchDeleteItem
implements
QuickPickItem
{
pr
otected
get
shortCommit
():
string
{
return
(
this
.
ref
.
commit
||
''
).
substr
(
0
,
8
);
}
protected
get
treeish
():
string
|
undefined
{
return
this
.
ref
.
name
;
}
get
label
():
string
{
return
this
.
ref
.
name
||
this
.
shortCommit
;
}
pr
ivate
get
shortCommit
():
string
{
return
(
this
.
ref
.
commit
||
''
).
substr
(
0
,
8
);
}
get
branchName
():
string
|
undefined
{
return
this
.
ref
.
name
;
}
get
label
():
string
{
return
this
.
branchName
||
''
;
}
get
description
():
string
{
return
this
.
shortCommit
;
}
constructor
(
protected
ref
:
Ref
)
{
}
async
run
(
model
:
Model
):
Promise
<
void
>
{
const
ref
=
this
.
treeish
;
constructor
(
private
ref
:
Ref
)
{
}
if
(
!
ref
)
{
async
run
(
model
:
Model
,
force
?:
boolean
):
Promise
<
void
>
{
if
(
!
this
.
branchName
)
{
return
;
}
await
model
.
deleteBranch
(
ref
);
await
model
.
deleteBranch
(
this
.
branchName
,
force
);
}
}
...
...
@@ -720,22 +717,40 @@ export class CommandCenter {
}
@
command
(
'
git.deleteBranch
'
)
async
deleteBranch
(
branchName
:
string
):
Promise
<
void
>
{
if
(
typeof
branchName
===
'
string
'
)
{
return
await
this
.
model
.
deleteBranch
(
branchName
);
}
const
currentHead
=
this
.
model
.
HEAD
&&
this
.
model
.
HEAD
.
name
;
const
heads
=
this
.
model
.
refs
.
filter
(
ref
=>
ref
.
type
===
RefType
.
Head
&&
ref
.
name
!==
currentHead
)
.
map
(
ref
=>
new
BranchDeleteItem
(
ref
));
async
deleteBranch
(
name
:
string
,
force
?:
boolean
):
Promise
<
void
>
{
let
run
:
(
force
?:
boolean
)
=>
Promise
<
void
>
;
if
(
typeof
name
===
'
string
'
)
{
run
=
force
=>
this
.
model
.
deleteBranch
(
name
,
force
);
}
else
{
const
currentHead
=
this
.
model
.
HEAD
&&
this
.
model
.
HEAD
.
name
;
const
heads
=
this
.
model
.
refs
.
filter
(
ref
=>
ref
.
type
===
RefType
.
Head
&&
ref
.
name
!==
currentHead
)
.
map
(
ref
=>
new
BranchDeleteItem
(
ref
));
const
placeHolder
=
'
Select a branch to delete
'
;
const
choice
=
await
window
.
showQuickPick
<
BranchDeleteItem
>
(
heads
,
{
placeHolder
});
const
placeHolder
=
'
Select a branch to delete
'
;
const
choice
=
await
window
.
showQuickPick
<
BranchDeleteItem
>
(
heads
,
{
placeHolder
});
if
(
!
choice
)
{
return
;
if
(
!
choice
)
{
return
;
}
name
=
choice
.
branchName
||
''
;
run
=
force
=>
choice
.
run
(
this
.
model
,
force
);
}
await
choice
.
run
(
this
.
model
);
try
{
await
run
(
force
);
}
catch
(
err
)
{
if
(
err
.
gitErrorCode
!==
GitErrorCodes
.
BranchNotFullyMerged
)
{
throw
err
;
}
const
message
=
localize
(
'
confirm force delete branch
'
,
"
The branch '{0}' is not fully merged. Delete anyway?
"
,
name
);
const
yes
=
localize
(
'
delete branch
'
,
"
Delete Branch
"
);
const
pick
=
await
window
.
showWarningMessage
(
message
,
yes
);
if
(
pick
===
yes
)
{
await
run
(
true
);
}
}
}
@
command
(
'
git.pull
'
)
...
...
extensions/git/src/git.ts
浏览文件 @
b348a0b7
...
...
@@ -273,7 +273,8 @@ export const GitErrorCodes = {
CantCreatePipe
:
'
CantCreatePipe
'
,
CantAccessRemote
:
'
CantAccessRemote
'
,
RepositoryNotFound
:
'
RepositoryNotFound
'
,
RepositoryIsLocked
:
'
RepositoryIsLocked
'
RepositoryIsLocked
:
'
RepositoryIsLocked
'
,
BranchNotFullyMerged
:
'
BranchNotFullyMerged
'
};
function
getGitErrorCode
(
stderr
:
string
):
string
|
undefined
{
...
...
@@ -291,6 +292,8 @@ function getGitErrorCode(stderr: string): string | undefined {
return
GitErrorCodes
.
RepositoryNotFound
;
}
else
if
(
/unable to access/
.
test
(
stderr
))
{
return
GitErrorCodes
.
CantAccessRemote
;
}
else
if
(
/branch '.+' is not fully merged/
.
test
(
stderr
))
{
return
GitErrorCodes
.
BranchNotFullyMerged
;
}
return
void
0
;
...
...
@@ -650,8 +653,8 @@ export class Repository {
await
this
.
run
(
args
);
}
async
deleteBranch
(
name
:
string
):
Promise
<
void
>
{
const
args
=
[
'
branch
'
,
'
-d
'
,
name
];
async
deleteBranch
(
name
:
string
,
force
?:
boolean
):
Promise
<
void
>
{
const
args
=
[
'
branch
'
,
force
?
'
-D
'
:
'
-d
'
,
name
];
await
this
.
run
(
args
);
}
...
...
extensions/git/src/model.ts
浏览文件 @
b348a0b7
...
...
@@ -454,8 +454,8 @@ export class Model implements Disposable {
await
this
.
run
(
Operation
.
Branch
,
()
=>
this
.
repository
.
branch
(
name
,
true
));
}
async
deleteBranch
(
name
:
string
):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
DeleteBranch
,
()
=>
this
.
repository
.
deleteBranch
(
name
));
async
deleteBranch
(
name
:
string
,
force
?:
boolean
):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
DeleteBranch
,
()
=>
this
.
repository
.
deleteBranch
(
name
,
force
));
}
async
checkout
(
treeish
:
string
):
Promise
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录