Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a96e8775
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,发现更多精彩内容 >>
提交
a96e8775
编写于
5月 24, 2018
作者:
R
Rachel Macfarlane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A bit of code cleanup
上级
ec22a1e2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
112 addition
and
77 deletion
+112
-77
extensions/git-extended/src/common/pullRequestOverview.ts
extensions/git-extended/src/common/pullRequestOverview.ts
+2
-2
extensions/git-extended/src/models/pullRequestModel.ts
extensions/git-extended/src/models/pullRequestModel.ts
+38
-2
extensions/git-extended/src/review/reviewManager.ts
extensions/git-extended/src/review/reviewManager.ts
+72
-73
未找到文件。
extensions/git-extended/src/common/pullRequestOverview.ts
浏览文件 @
a96e8775
...
...
@@ -6,7 +6,7 @@
import
*
as
vscode
from
'
vscode
'
;
import
*
as
path
from
'
path
'
;
import
{
PullRequestModel
}
from
'
../models/pullRequestModel
'
;
import
{
PullRequestModel
,
PullRequest
}
from
'
../models/pullRequestModel
'
;
import
{
ReviewManager
}
from
'
../review/reviewManager
'
;
export
class
PullRequestOverviewPanel
{
...
...
@@ -107,7 +107,7 @@ export class PullRequestOverviewPanel {
});
return
;
case
'
pr.close
'
:
vscode
.
commands
.
executeCommand
(
'
pr.close
'
,
this
.
_pullRequest
).
then
(
pr
=>
{
vscode
.
commands
.
executeCommand
<
PullRequest
>
(
'
pr.close
'
,
this
.
_pullRequest
).
then
(
pr
=>
{
if
(
pr
)
{
this
.
_pullRequest
.
update
(
pr
);
this
.
_panel
.
webview
.
postMessage
({
...
...
extensions/git-extended/src/models/pullRequestModel.ts
浏览文件 @
a96e8775
...
...
@@ -34,6 +34,42 @@ export interface IAccount {
privateRepositoryInPlanCount
?:
number
;
}
export
interface
Repo
{
label
:
string
;
ref
:
string
;
repo
:
any
;
sha
:
string
;
}
// This interface is incomplete
export
interface
PullRequest
{
additions
:
number
;
assignee
:
any
;
assignees
:
any
[];
author_association
:
string
;
base
:
Repo
;
body
:
string
;
changed_files
:
number
;
closed_at
:
string
;
comments
:
number
;
commits
:
number
;
created_at
:
string
;
head
:
Repo
;
html_url
:
string
;
id
:
number
;
labels
:
any
[];
locked
:
boolean
;
maintainer_can_modify
:
boolean
;
merge_commit_sha
;
boolean
;
mergable
:
boolean
;
number
:
number
;
rebaseable
:
boolean
;
state
:
string
;
title
:
string
;
updated_at
:
string
;
user
:
any
;
}
export
class
PullRequestModel
{
public
prNumber
:
number
;
public
title
:
string
;
...
...
@@ -56,11 +92,11 @@ export class PullRequestModel {
public
head
:
GitHubRef
;
public
base
:
GitHubRef
;
constructor
(
public
readonly
otcokit
:
any
,
public
readonly
remote
:
Remote
,
public
prItem
:
any
)
{
constructor
(
public
readonly
otcokit
:
any
,
public
readonly
remote
:
Remote
,
public
prItem
:
PullRequest
)
{
this
.
update
(
prItem
);
}
update
(
prItem
:
any
)
{
update
(
prItem
:
PullRequest
)
{
this
.
prNumber
=
prItem
.
number
;
this
.
title
=
prItem
.
title
;
this
.
html_url
=
prItem
.
html_url
;
...
...
extensions/git-extended/src/review/reviewManager.ts
浏览文件 @
a96e8775
...
...
@@ -25,7 +25,6 @@ export class ReviewManager implements vscode.DecorationProvider {
private
static
_instance
:
ReviewManager
;
private
_documentCommentProvider
:
vscode
.
Disposable
;
private
_workspaceCommentProvider
:
vscode
.
Disposable
;
private
_command
:
vscode
.
Disposable
;
private
_disposables
:
vscode
.
Disposable
[];
private
_comments
:
Comment
[]
=
[];
...
...
@@ -37,38 +36,16 @@ export class ReviewManager implements vscode.DecorationProvider {
private
_onDidChangeCommentThreads
=
new
vscode
.
EventEmitter
<
vscode
.
CommentThreadChangedEvent
>
();
private
_prFileChangesProvider
:
FileChangesProvider
;
get
prFileChangesProvider
()
{
if
(
!
this
.
_prFileChangesProvider
)
{
this
.
_prFileChangesProvider
=
new
FileChangesProvider
(
this
.
_context
);
this
.
_disposables
.
push
(
this
.
_prFileChangesProvider
);
}
return
this
.
_prFileChangesProvider
;
}
private
_statusBarItem
:
vscode
.
StatusBarItem
;
get
statusBarItem
()
{
if
(
!
this
.
_statusBarItem
)
{
this
.
_statusBarItem
=
vscode
.
window
.
createStatusBarItem
(
vscode
.
StatusBarAlignment
.
Left
);
}
return
this
.
_statusBarItem
;
}
private
_prNumber
:
number
;
private
_pr
:
PullRequestModel
;
get
currentPullRequest
():
PullRequestModel
{
return
this
.
_pr
;
}
private
constructor
(
private
_context
:
vscode
.
ExtensionContext
,
private
_repository
:
Repository
)
{
this
.
_documentCommentProvider
=
null
;
this
.
_workspaceCommentProvider
=
null
;
this
.
_command
=
null
;
this
.
_disposables
=
[];
let
gitContentProvider
=
new
GitContentProvider
(
_repository
);
gitContentProvider
.
registerTextDocumentContentFallback
(
this
.
provideTextDocumentContent
.
bind
(
this
));
...
...
@@ -97,6 +74,27 @@ export class ReviewManager implements vscode.DecorationProvider {
return
ReviewManager
.
_instance
;
}
get
prFileChangesProvider
()
{
if
(
!
this
.
_prFileChangesProvider
)
{
this
.
_prFileChangesProvider
=
new
FileChangesProvider
(
this
.
_context
);
this
.
_disposables
.
push
(
this
.
_prFileChangesProvider
);
}
return
this
.
_prFileChangesProvider
;
}
get
statusBarItem
()
{
if
(
!
this
.
_statusBarItem
)
{
this
.
_statusBarItem
=
vscode
.
window
.
createStatusBarItem
(
vscode
.
StatusBarAlignment
.
Left
);
}
return
this
.
_statusBarItem
;
}
get
currentPullRequest
():
PullRequestModel
{
return
this
.
_pr
;
}
private
pollForStatusChange
()
{
setTimeout
(
async
()
=>
{
await
this
.
updateComments
();
...
...
@@ -316,59 +314,64 @@ export class ReviewManager implements vscode.DecorationProvider {
}
private
async
getPullRequestData
(
pr
:
PullRequestModel
):
Promise
<
void
>
{
this
.
_comments
=
await
pr
.
getComments
();
let
activeComments
=
this
.
_comments
.
filter
(
comment
=>
comment
.
position
);
let
outdatedComments
=
this
.
_comments
.
filter
(
comment
=>
!
comment
.
position
);
const
data
=
await
pr
.
getFiles
();
await
pr
.
fetchBaseCommitSha
();
let
baseSha
=
pr
.
base
.
sha
;
let
headSha
=
pr
.
head
.
sha
;
const
richContentChanges
=
await
parseDiff
(
data
,
this
.
_repository
,
baseSha
);
this
.
_localFileChanges
=
richContentChanges
.
map
(
change
=>
{
let
changedItem
=
new
FileChangeTreeItem
(
pr
,
change
.
fileName
,
change
.
status
,
change
.
fileName
,
change
.
blobUrl
,
toGitUri
(
vscode
.
Uri
.
parse
(
change
.
fileName
),
null
,
null
,
change
.
status
===
GitChangeType
.
DELETE
?
''
:
pr
.
prItem
.
head
.
sha
,
{}),
toGitUri
(
vscode
.
Uri
.
parse
(
change
.
fileName
),
null
,
null
,
change
.
status
===
GitChangeType
.
ADD
?
''
:
pr
.
prItem
.
base
.
sha
,
{}),
this
.
_repository
.
path
,
change
.
diffHunks
);
changedItem
.
sha
=
headSha
;
changedItem
.
comments
=
activeComments
.
filter
(
comment
=>
comment
.
path
===
changedItem
.
fileName
);
return
changedItem
;
});
let
commitsGroup
=
groupBy
(
outdatedComments
,
comment
=>
comment
.
original_commit_id
);
this
.
_obsoleteFileChanges
=
[];
for
(
let
commit
in
commitsGroup
)
{
let
commentsForCommit
=
commitsGroup
[
commit
];
let
commentsForFile
=
groupBy
(
commentsForCommit
,
comment
=>
comment
.
path
);
for
(
let
fileName
in
commentsForFile
)
{
let
oldComments
=
commentsForFile
[
fileName
];
let
obsoleteFileChange
=
new
FileChangeTreeItem
(
try
{
this
.
_comments
=
await
pr
.
getComments
();
let
activeComments
=
this
.
_comments
.
filter
(
comment
=>
comment
.
position
);
let
outdatedComments
=
this
.
_comments
.
filter
(
comment
=>
!
comment
.
position
);
const
data
=
await
pr
.
getFiles
();
await
pr
.
fetchBaseCommitSha
();
let
baseSha
=
pr
.
base
.
sha
;
let
headSha
=
pr
.
head
.
sha
;
const
richContentChanges
=
await
parseDiff
(
data
,
this
.
_repository
,
baseSha
);
this
.
_localFileChanges
=
richContentChanges
.
map
(
change
=>
{
let
changedItem
=
new
FileChangeTreeItem
(
pr
,
fileName
,
GitChangeType
.
MODIFY
,
fileName
,
nul
l
,
toGitUri
(
vscode
.
Uri
.
parse
(
path
.
join
(
`commit~
${
commit
.
substr
(
0
,
8
)}
`
,
fileName
)),
fileName
,
null
,
oldComments
[
0
].
original_commit_id
,
{}),
toGitUri
(
vscode
.
Uri
.
parse
(
path
.
join
(
`commit~
${
commit
.
substr
(
0
,
8
)}
`
,
fileName
)),
fileName
,
null
,
oldComments
[
0
].
original_commit_id
,
{}),
change
.
fileName
,
change
.
status
,
change
.
fileName
,
change
.
blobUr
l
,
toGitUri
(
vscode
.
Uri
.
parse
(
change
.
fileName
),
null
,
null
,
change
.
status
===
GitChangeType
.
DELETE
?
''
:
pr
.
prItem
.
head
.
sha
,
{}),
toGitUri
(
vscode
.
Uri
.
parse
(
change
.
fileName
),
null
,
null
,
change
.
status
===
GitChangeType
.
ADD
?
''
:
pr
.
prItem
.
base
.
sha
,
{}),
this
.
_repository
.
path
,
[]
// @todo Peng.
change
.
diffHunks
);
changedItem
.
sha
=
headSha
;
changedItem
.
comments
=
activeComments
.
filter
(
comment
=>
comment
.
path
===
changedItem
.
fileName
);
return
changedItem
;
});
obsoleteFileChange
.
sha
=
commit
;
obsoleteFileChange
.
comments
=
oldComments
;
this
.
_obsoleteFileChanges
.
push
(
obsoleteFileChange
);
let
commitsGroup
=
groupBy
(
outdatedComments
,
comment
=>
comment
.
original_commit_id
);
this
.
_obsoleteFileChanges
=
[];
for
(
let
commit
in
commitsGroup
)
{
let
commentsForCommit
=
commitsGroup
[
commit
];
let
commentsForFile
=
groupBy
(
commentsForCommit
,
comment
=>
comment
.
path
);
for
(
let
fileName
in
commentsForFile
)
{
let
oldComments
=
commentsForFile
[
fileName
];
let
obsoleteFileChange
=
new
FileChangeTreeItem
(
pr
,
fileName
,
GitChangeType
.
MODIFY
,
fileName
,
null
,
toGitUri
(
vscode
.
Uri
.
parse
(
path
.
join
(
`commit~
${
commit
.
substr
(
0
,
8
)}
`
,
fileName
)),
fileName
,
null
,
oldComments
[
0
].
original_commit_id
,
{}),
toGitUri
(
vscode
.
Uri
.
parse
(
path
.
join
(
`commit~
${
commit
.
substr
(
0
,
8
)}
`
,
fileName
)),
fileName
,
null
,
oldComments
[
0
].
original_commit_id
,
{}),
this
.
_repository
.
path
,
[]
// @todo Peng.
);
obsoleteFileChange
.
sha
=
commit
;
obsoleteFileChange
.
comments
=
oldComments
;
this
.
_obsoleteFileChanges
.
push
(
obsoleteFileChange
);
}
}
return
Promise
.
resolve
(
null
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
return
Promise
.
resolve
(
null
);
}
private
outdatedCommentsToCommentThreads
(
fileChange
:
FileChangeTreeItem
,
comments
:
Comment
[],
collapsibleState
:
vscode
.
CommentThreadCollapsibleState
=
vscode
.
CommentThreadCollapsibleState
.
Expanded
):
vscode
.
CommentThread
[]
{
...
...
@@ -687,10 +690,6 @@ export class ReviewManager implements vscode.DecorationProvider {
this
.
_pr
=
null
;
this
.
_updateMessageShown
=
false
;
if
(
this
.
_command
)
{
this
.
_command
.
dispose
();
}
if
(
this
.
_documentCommentProvider
)
{
this
.
_documentCommentProvider
.
dispose
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录