Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3fdf0bcc
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,发现更多精彩内容 >>
提交
3fdf0bcc
编写于
4月 08, 2018
作者:
R
Ryuichi Inagaki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ref #44776 Get previous commits as part of commit info
上级
d562ebbf
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
9 addition
and
6 deletion
+9
-6
extensions/git/src/git.ts
extensions/git/src/git.ts
+4
-3
extensions/git/src/test/git.test.ts
extensions/git/src/test/git.test.ts
+5
-3
未找到文件。
extensions/git/src/git.ts
浏览文件 @
3fdf0bcc
...
...
@@ -481,6 +481,7 @@ export class Git {
export
interface
Commit
{
hash
:
string
;
message
:
string
;
previousHashes
:
string
[];
}
export
class
GitStatusParser
{
...
...
@@ -1287,14 +1288,14 @@ export class Repository {
}
async
getCommit
(
ref
:
string
):
Promise
<
Commit
>
{
const
result
=
await
this
.
run
([
'
show
'
,
'
-s
'
,
'
--format=%H
\n
%B
'
,
ref
]);
const
match
=
/^
([
0-9a-f
]{40})\n([^]
*
)
$/m
.
exec
(
result
.
stdout
.
trim
());
const
result
=
await
this
.
run
([
'
show
'
,
'
-s
'
,
'
--format=%H
\n
%
P
\n
%
B
'
,
ref
]);
const
match
=
/^
([
0-9a-f
]{40})\n(
.*
)\n(
[^]
*
)
$/m
.
exec
(
result
.
stdout
.
trim
());
if
(
!
match
)
{
return
Promise
.
reject
<
Commit
>
(
'
bad commit format
'
);
}
return
{
hash
:
match
[
1
],
message
:
match
[
2
]
};
return
{
hash
:
match
[
1
],
message
:
match
[
3
],
previousHashes
:
[
match
[
2
]
]
};
}
async
updateSubmodules
(
paths
:
string
[]):
Promise
<
void
>
{
...
...
extensions/git/src/test/git.test.ts
浏览文件 @
3fdf0bcc
...
...
@@ -181,16 +181,18 @@ suite('git', () => {
test
(
'
get commit
'
,
async
()
=>
{
const
spawnOption
=
{};
const
gitOutput
=
`52c293a05038d865604c2284aa8698bd087915a1
8e5a374372b8393906c7e380dbb09349c5385554
This is a commit message.`
;
const
git
=
sinon
.
createStubInstance
(
Git
);
git
.
exec
=
sinon
.
stub
()
.
withArgs
(
'
REPOSITORY_ROOT
'
,
[
'
show
'
,
'
-s
'
,
'
--format=%H
\n
%
B
'
,
'
REF
'
],
spawnOption
)
.
withArgs
(
'
REPOSITORY_ROOT
'
,
[
'
show
'
,
'
-s
'
,
'
--format=%H
\n
%
P
\n
%B
'
,
'
REF_SINGLE_PARENT
'
],
spawnOption
)
.
returns
(
Promise
.
resolve
({
stdout
:
gitOutput
}));
const
repository
=
new
Repository
(
git
,
'
REPOSITORY_ROOT
'
);
assert
.
deepEqual
(
await
repository
.
getCommit
(
'
REF
'
),
{
assert
.
deepEqual
(
await
repository
.
getCommit
(
'
REF
_SINGLE_PARENT
'
),
{
hash
:
'
52c293a05038d865604c2284aa8698bd087915a1
'
,
message
:
'
This is a commit message.
'
message
:
'
This is a commit message.
'
,
previousHashes
:
[
'
8e5a374372b8393906c7e380dbb09349c5385554
'
]
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录