Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7c2ea174
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,发现更多精彩内容 >>
提交
7c2ea174
编写于
2月 08, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: commit commands
上级
a0b3d09a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
22 deletion
+44
-22
extensions/git/package.json
extensions/git/package.json
+4
-4
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+33
-17
extensions/git/src/model.ts
extensions/git/src/model.ts
+7
-1
未找到文件。
extensions/git/package.json
浏览文件 @
7c2ea174
...
...
@@ -227,22 +227,22 @@
{
"command"
:
"git.commitStaged"
,
"group"
:
"3_commit"
,
"when"
:
"scmProvider ==
none
"
"when"
:
"scmProvider ==
git
"
},
{
"command"
:
"git.commitStagedSigned"
,
"group"
:
"3_commit"
,
"when"
:
"scmProvider ==
none
"
"when"
:
"scmProvider ==
git
"
},
{
"command"
:
"git.commitAll"
,
"group"
:
"3_commit"
,
"when"
:
"scmProvider ==
none
"
"when"
:
"scmProvider ==
git
"
},
{
"command"
:
"git.commitAllSigned"
,
"group"
:
"3_commit"
,
"when"
:
"scmProvider ==
none
"
"when"
:
"scmProvider ==
git
"
},
{
"command"
:
"git.undoCommit"
,
...
...
extensions/git/src/commands.ts
浏览文件 @
7c2ea174
...
...
@@ -7,7 +7,7 @@
import
{
Uri
,
commands
,
scm
,
Disposable
,
SCMResourceGroup
,
SCMResource
,
window
,
workspace
,
QuickPickItem
,
OutputChannel
}
from
'
vscode
'
;
import
{
IRef
,
RefType
}
from
'
./git
'
;
import
{
Model
,
Resource
,
Status
}
from
'
./model
'
;
import
{
Model
,
Resource
,
Status
,
CommitOptions
}
from
'
./model
'
;
import
*
as
path
from
'
path
'
;
import
*
as
nls
from
'
vscode-nls
'
;
...
...
@@ -322,31 +322,39 @@ export class CommandCenter {
await
this
.
model
.
clean
(...
this
.
model
.
workingTreeGroup
.
resources
);
}
private
async
_commit
(
fn
:
()
=>
Promise
<
string
>
):
Promise
<
boolean
>
{
if
(
this
.
model
.
indexGroup
.
resources
.
length
===
0
&&
this
.
model
.
workingTreeGroup
.
resources
.
length
===
0
)
{
private
async
smartCommit
(
getCommitMessage
:
()
=>
Promise
<
string
>
,
opts
?:
CommitOptions
):
Promise
<
boolean
>
{
if
(
!
opts
)
{
opts
=
{
all
:
this
.
model
.
indexGroup
.
resources
.
length
===
0
};
}
if
(
// no changes
(
this
.
model
.
indexGroup
.
resources
.
length
===
0
&&
this
.
model
.
workingTreeGroup
.
resources
.
length
===
0
)
// or no staged changes and not `all`
||
(
!
opts
.
all
&&
this
.
model
.
indexGroup
.
resources
.
length
===
0
)
)
{
window
.
showInformationMessage
(
localize
(
'
no changes
'
,
"
There are no changes to commit.
"
));
return
false
;
}
const
message
=
await
fn
();
const
message
=
await
getCommitMessage
();
if
(
!
message
)
{
// TODO@joao: show modal dialog to confirm empty message commit
return
false
;
}
const
all
=
this
.
model
.
indexGroup
.
resources
.
length
===
0
;
await
this
.
model
.
commit
(
message
,
{
all
});
await
this
.
model
.
commit
(
message
,
opts
);
return
true
;
}
@
CommandCenter
.
Command
(
'
git.commit
'
)
@
CommandCenter
.
CatchErrors
async
commit
():
Promise
<
void
>
{
private
async
commitWithAnyInput
(
opts
?:
CommitOptions
):
Promise
<
void
>
{
const
message
=
scm
.
inputBox
.
value
;
const
didCommit
=
await
this
.
_commit
(
async
()
=>
{
const
getCommitMessage
=
async
()
=>
{
if
(
message
)
{
return
message
;
}
...
...
@@ -355,17 +363,25 @@ export class CommandCenter {
placeHolder
:
localize
(
'
commit message
'
,
"
Commit message
"
),
prompt
:
localize
(
'
provide commit message
'
,
"
Please provide a commit message
"
)
});
});
};
const
didCommit
=
await
this
.
smartCommit
(
getCommitMessage
,
opts
);
if
(
message
&&
didCommit
)
{
scm
.
inputBox
.
value
=
''
;
}
}
@
CommandCenter
.
Command
(
'
git.commit
'
)
@
CommandCenter
.
CatchErrors
async
commit
():
Promise
<
void
>
{
await
this
.
commitWithAnyInput
();
}
@
CommandCenter
.
Command
(
'
git.commitWithInput
'
)
@
CommandCenter
.
CatchErrors
async
commitWithInput
():
Promise
<
void
>
{
const
didCommit
=
await
this
.
_c
ommit
(
async
()
=>
scm
.
inputBox
.
value
);
const
didCommit
=
await
this
.
smartC
ommit
(
async
()
=>
scm
.
inputBox
.
value
);
if
(
didCommit
)
{
scm
.
inputBox
.
value
=
''
;
...
...
@@ -375,25 +391,25 @@ export class CommandCenter {
@
CommandCenter
.
Command
(
'
git.commitStaged
'
)
@
CommandCenter
.
CatchErrors
async
commitStaged
():
Promise
<
void
>
{
await
Promise
.
reject
(
'
not implemented
'
);
await
this
.
commitWithAnyInput
({
all
:
false
}
);
}
@
CommandCenter
.
Command
(
'
git.commitStagedSigned
'
)
@
CommandCenter
.
CatchErrors
async
commitStagedSigned
():
Promise
<
void
>
{
await
Promise
.
reject
(
'
not implemented
'
);
await
this
.
commitWithAnyInput
({
all
:
false
,
signoff
:
true
}
);
}
@
CommandCenter
.
Command
(
'
git.commitAll
'
)
@
CommandCenter
.
CatchErrors
async
commitAll
():
Promise
<
void
>
{
await
Promise
.
reject
(
'
not implemented
'
);
await
this
.
commitWithAnyInput
({
all
:
true
}
);
}
@
CommandCenter
.
Command
(
'
git.commitAllSigned
'
)
@
CommandCenter
.
CatchErrors
async
commitAllSigned
():
Promise
<
void
>
{
await
Promise
.
reject
(
'
not implemented
'
);
await
this
.
commitWithAnyInput
({
all
:
true
,
signoff
:
true
}
);
}
@
CommandCenter
.
Command
(
'
git.undoCommit
'
)
...
...
extensions/git/src/model.ts
浏览文件 @
7c2ea174
...
...
@@ -195,6 +195,12 @@ class OperationsImpl implements Operations {
}
}
export
interface
CommitOptions
{
all
?:
boolean
;
amend
?:
boolean
;
signoff
?:
boolean
;
}
export
class
Model
{
private
_onDidChange
=
new
EventEmitter
<
SCMResourceGroup
[]
>
();
...
...
@@ -299,7 +305,7 @@ export class Model {
}
@
throttle
async
commit
(
message
:
string
,
opts
:
{
all
?:
boolean
,
amend
?:
boolean
,
signoff
?:
boolean
}
=
Object
.
create
(
null
)):
Promise
<
void
>
{
async
commit
(
message
:
string
,
opts
:
CommitOptions
=
Object
.
create
(
null
)):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Commit
,
async
()
=>
{
if
(
opts
.
all
)
{
await
this
.
repository
.
add
([]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录