Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
59de8924
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,发现更多精彩内容 >>
提交
59de8924
编写于
5月 09, 2018
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use status bar item to indictate review mode switching.
上级
0f0e1bbc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
20 deletion
+42
-20
extensions/git-extended/src/common/models/repository.ts
extensions/git-extended/src/common/models/repository.ts
+2
-2
extensions/git-extended/src/review/reviewManager.ts
extensions/git-extended/src/review/reviewManager.ts
+35
-13
extensions/git-extended/src/services/pullRequestService.ts
extensions/git-extended/src/services/pullRequestService.ts
+5
-5
未找到文件。
extensions/git-extended/src/common/models/repository.ts
浏览文件 @
59de8924
...
...
@@ -115,7 +115,7 @@ export class Repository {
if
(
this
.
_HEAD
.
upstream
.
remote
)
{
let
currentRemote
=
this
.
_remotes
.
filter
(
remote
=>
remote
.
remoteName
===
this
.
_HEAD
.
upstream
.
remote
);
if
(
currentRemote
&&
currentRemote
.
length
)
{
this
.
_cloneUrl
=
new
UriString
(
currentRemote
[
0
].
url
);
this
.
_cloneUrl
=
new
UriString
(
currentRemote
[
0
].
url
);
}
}
...
...
@@ -199,7 +199,7 @@ export class Repository {
const
result
=
await
GitProcess
.
exec
([
'
rev-parse
'
,
name
],
this
.
path
);
if
(
result
.
exitCode
!==
0
||
!
result
.
stdout
)
{
return
Promise
.
reject
<
Branch
>
(
new
Error
(
'
No such branch
'
))
;
return
null
;
}
const
commit
=
result
.
stdout
.
trim
();
...
...
extensions/git-extended/src/review/reviewManager.ts
浏览文件 @
59de8924
...
...
@@ -42,9 +42,9 @@ export class ReviewManager implements vscode.DecorationProvider {
private
_onDidChangeCommentThreads
=
new
vscode
.
EventEmitter
<
vscode
.
CommentThreadChangedEvent
>
();
private
_prFileChangesProvider
:
FileChangesProvider
|
undefined
;
private
_prFileChangesProvider
:
FileChangesProvider
;
get
prFileChangesProvider
()
{
if
(
this
.
_prFileChangesProvider
===
undefined
)
{
if
(
!
this
.
_prFileChangesProvider
)
{
this
.
_prFileChangesProvider
=
new
FileChangesProvider
(
this
.
_context
);
this
.
_disposables
.
push
(
this
.
_prFileChangesProvider
);
}
...
...
@@ -52,6 +52,15 @@ export class ReviewManager implements vscode.DecorationProvider {
return
this
.
_prFileChangesProvider
;
}
private
_statusBarItem
:
vscode
.
StatusBarItem
;
get
statusBarItem
()
{
if
(
!
this
.
_statusBarItem
)
{
this
.
_statusBarItem
=
vscode
.
window
.
createStatusBarItem
(
vscode
.
StatusBarAlignment
.
Left
);
}
return
this
.
_statusBarItem
;
}
constructor
(
private
_context
:
vscode
.
ExtensionContext
,
private
_repository
:
Repository
,
...
...
@@ -91,7 +100,7 @@ export class ReviewManager implements vscode.DecorationProvider {
}
catch
(
e
)
{
}
if
(
!
localInfo
)
{
this
.
clear
();
this
.
clear
(
true
);
return
;
}
...
...
@@ -101,21 +110,21 @@ export class ReviewManager implements vscode.DecorationProvider {
let
branch
=
this
.
_repository
.
HEAD
;
if
(
!
branch
)
{
this
.
clear
();
this
.
clear
(
true
);
return
;
}
let
remote
=
branch
.
upstream
?
branch
.
upstream
.
remote
:
null
;
if
(
!
remote
)
{
this
.
clear
();
this
.
clear
(
true
);
return
;
}
// we switch to another PR, let's clean up first.
this
.
clear
();
this
.
clear
(
false
);
this
.
_prNumber
=
localInfo
.
prNumber
;
this
.
_lastCommitSha
=
null
;
let
githubRepo
=
this
.
_repository
.
githubRepositories
.
find
(
repo
=>
repo
.
remote
.
remoteName
===
remote
);
let
githubRepo
=
this
.
_repository
.
githubRepositories
.
find
(
repo
=>
repo
.
remote
.
owner
.
toLocaleLowerCase
()
===
localInfo
.
owner
.
toLocaleLowerCase
()
);
if
(
!
githubRepo
)
{
return
;
// todo, should show warning
...
...
@@ -175,6 +184,9 @@ export class ReviewManager implements vscode.DecorationProvider {
this
.
_onDidChangeDecorations
.
fire
();
this
.
registerCommentProvider
();
this
.
statusBarItem
.
text
=
'
$(sync) Pull Request #
'
+
this
.
_prNumber
;
this
.
statusBarItem
.
show
();
}
private
async
updateComments
():
Promise
<
void
>
{
...
...
@@ -435,7 +447,11 @@ export class ReviewManager implements vscode.DecorationProvider {
}
async
switch
(
pr
:
PullRequestModel
)
{
this
.
statusBarItem
.
text
=
'
$(sync~spin) Switching to Review Mode
'
;
this
.
statusBarItem
.
show
();
try
{
// todo, check if HEAD is dirty
let
localBranches
=
await
this
.
_pullRequestService
.
getLocalBranches
(
this
.
_repository
,
pr
);
if
(
localBranches
.
length
>
0
)
{
...
...
@@ -446,13 +462,12 @@ export class ReviewManager implements vscode.DecorationProvider {
}
}
catch
(
e
)
{
vscode
.
window
.
showErrorMessage
(
e
);
// todo, we should try to recover, for example, git checkout succeeds but set config fails.
return
;
}
await
this
.
_repository
.
status
();
}
clear
()
{
clear
(
quitReviewMode
:
boolean
)
{
this
.
_prNumber
=
null
;
if
(
this
.
_command
)
{
...
...
@@ -467,13 +482,20 @@ export class ReviewManager implements vscode.DecorationProvider {
this
.
_workspaceCommentProvider
.
dispose
();
}
if
(
this
.
_prFileChangesProvider
)
{
this
.
prFileChangesProvider
.
hide
();
if
(
quitReviewMode
)
{
if
(
this
.
_statusBarItem
)
{
this
.
_statusBarItem
.
hide
();
}
if
(
this
.
_prFileChangesProvider
)
{
this
.
prFileChangesProvider
.
hide
();
}
}
}
dispose
()
{
this
.
clear
();
this
.
clear
(
true
);
this
.
_disposables
.
forEach
(
dispose
=>
{
dispose
.
dispose
();
});
...
...
extensions/git-extended/src/services/pullRequestService.ts
浏览文件 @
59de8924
...
...
@@ -31,7 +31,7 @@ export class PullRequestService {
let
remoteName
=
await
PullRequestService
.
createRemote
(
repository
,
pullRequest
.
head
.
repositoryCloneUrl
);
await
repository
.
fetch
(
remoteName
,
refSpec
);
await
repository
.
checkout
(
refSpec
);
await
repository
.
checkout
(
localBranchName
);
await
repository
.
setTrackingBranch
(
localBranchName
,
`refs/remotes/
${
remoteName
}
/
${
pullRequest
.
head
.
ref
}
`
);
}
...
...
@@ -79,7 +79,7 @@ export class PullRequestService {
let
branch
=
null
;
try
{
branch
=
await
repository
.
getBranch
(
branchName
);
}
catch
(
e
)
{}
}
catch
(
e
)
{
}
if
(
!
branch
)
{
const
trackedBranchName
=
`refs/remotes/
${
remoteName
}
/
${
branchName
}
`
;
...
...
@@ -111,9 +111,9 @@ export class PullRequestService {
if
(
currentBranch
)
{
current
=
initial
+
'
-
'
+
index
++
;
}
else
{
break
;
}
break
;
}
return
current
.
replace
(
/-*$/g
,
''
);
...
...
@@ -182,7 +182,7 @@ export class PullRequestService {
var
uniqueName
=
name
;
var
number
=
1
;
while
(
repository
.
remotes
[
uniqueName
]
!==
null
)
{
while
(
repository
.
remotes
.
find
(
e
=>
e
.
remoteName
===
uniqueName
)
)
{
uniqueName
=
name
+
number
++
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录