Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
59ad3ecb
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,发现更多精彩内容 >>
提交
59ad3ecb
编写于
5月 08, 2018
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
no git extension api hack
上级
9c5d1018
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
104 addition
and
87 deletion
+104
-87
extensions/git-extended/package.json
extensions/git-extended/package.json
+11
-4
extensions/git-extended/src/extension.ts
extensions/git-extended/src/extension.ts
+16
-16
extensions/git-extended/src/prView/prProvider.ts
extensions/git-extended/src/prView/prProvider.ts
+3
-3
extensions/git-extended/src/review/fileChangesProvider.ts
extensions/git-extended/src/review/fileChangesProvider.ts
+55
-0
extensions/git-extended/src/review/reviewManager.ts
extensions/git-extended/src/review/reviewManager.ts
+16
-23
extensions/git/.vscode/launch.json
extensions/git/.vscode/launch.json
+0
-28
extensions/git/package.json
extensions/git/package.json
+1
-1
extensions/git/src/api.ts
extensions/git/src/api.ts
+2
-12
未找到文件。
extensions/git-extended/package.json
浏览文件 @
59ad3ecb
...
...
@@ -47,10 +47,17 @@
}
},
"views"
:
{
"scm"
:
[{
"id"
:
"pr"
,
"name"
:
"GitHub Pull Requests"
}]
"scm"
:
[
{
"id"
:
"pr"
,
"name"
:
"GitHub Pull Requests"
},
{
"id"
:
"prStatus"
,
"name"
:
"Changes From Pull Request"
,
"when"
:
"git:ispr"
}
]
},
"commands"
:
[{
"command"
:
"pr.refreshList"
,
...
...
extensions/git-extended/src/extension.ts
浏览文件 @
59ad3ecb
...
...
@@ -9,7 +9,7 @@ import { PRProvider } from './prView/prProvider';
import
{
Repository
}
from
'
./common/models/repository
'
;
import
{
Configuration
}
from
'
./configuration
'
;
import
{
Resource
}
from
'
./common/resources
'
;
import
{
ReviewM
ode
}
from
'
./review/reviewMode
'
;
import
{
ReviewM
anager
}
from
'
./review/reviewManager
'
;
import
{
CredentialStore
}
from
'
./credentials
'
;
import
{
PullRequestService
}
from
'
./services/pullRequestService
'
;
...
...
@@ -36,22 +36,22 @@ export async function activate(context: vscode.ExtensionContext) {
})
);
let
gitExt
=
vscode
.
extensions
.
getExtension
(
'
vscode.git
'
);
let
importedGitApi
=
gitExt
.
exports
;
let
repos
=
await
importedGitApi
.
getRepositories
();
let
repo
;
//
let gitExt = vscode.extensions.getExtension('vscode.git');
//
let importedGitApi = gitExt.exports;
//
let repos = await importedGitApi.getRepositories();
//
let repo;
if
(
!
repos
||
!
repos
.
length
)
{
let
waitForRepo
=
new
Promise
((
resolve
,
reject
)
=>
{
importedGitApi
.
onDidOpenRepository
(
repository
=>
{
resolve
(
repository
);
});
});
//
if (!repos || !repos.length) {
//
let waitForRepo = new Promise((resolve, reject) => {
//
importedGitApi.onDidOpenRepository(repository => {
//
resolve(repository);
//
});
//
});
repo
=
await
waitForRepo
;
}
else
{
repo
=
repos
[
0
];
}
//
repo = await waitForRepo;
//
} else {
//
repo = repos[0];
//
}
const
repository
=
new
Repository
(
rootPath
,
context
.
workspaceState
);
let
repositoryInitialized
=
false
;
...
...
@@ -63,7 +63,7 @@ export async function activate(context: vscode.ExtensionContext) {
let
credentialStore
=
new
CredentialStore
(
configuration
);
await
repository
.
connectGitHub
(
credentialStore
);
let
pullRequestService
=
new
PullRequestService
();
let
reviewMode
=
new
ReviewM
ode
(
repository
,
pullRequestService
,
context
.
workspaceState
,
repo
);
let
reviewMode
=
new
ReviewM
anager
(
context
,
repository
,
pullRequestService
,
context
.
workspaceState
);
await
(
new
PRProvider
(
context
,
configuration
,
reviewMode
)).
activate
(
repository
);
});
}
extensions/git-extended/src/prView/prProvider.ts
浏览文件 @
59ad3ecb
...
...
@@ -13,7 +13,7 @@ import { Configuration } from '../configuration';
import
{
parseComments
}
from
'
../common/comment
'
;
import
{
PRGroupTreeItem
,
FileChangeTreeItem
}
from
'
../common/treeItems
'
;
import
{
Resource
}
from
'
../common/resources
'
;
import
{
ReviewM
ode
}
from
'
../review/reviewMode
'
;
import
{
ReviewM
anager
}
from
'
../review/reviewManager
'
;
import
{
toPRUri
}
from
'
../common/uri
'
;
import
*
as
fs
from
'
fs
'
;
import
{
PullRequestModel
,
PRType
}
from
'
../common/models/pullRequestModel
'
;
...
...
@@ -22,13 +22,13 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
private
context
:
vscode
.
ExtensionContext
;
private
repository
:
Repository
;
private
configuration
:
Configuration
;
private
reviewMode
:
ReviewM
ode
;
private
reviewMode
:
ReviewM
anager
;
private
_onDidChangeTreeData
=
new
vscode
.
EventEmitter
<
PRGroupTreeItem
|
PullRequestModel
|
FileChangeTreeItem
|
undefined
>
();
readonly
onDidChangeTreeData
=
this
.
_onDidChangeTreeData
.
event
;
private
_onDidChange
=
new
vscode
.
EventEmitter
<
vscode
.
Uri
>
();
get
onDidChange
():
vscode
.
Event
<
vscode
.
Uri
>
{
return
this
.
_onDidChange
.
event
;
}
constructor
(
context
:
vscode
.
ExtensionContext
,
configuration
:
Configuration
,
reviewMode
:
ReviewM
ode
)
{
constructor
(
context
:
vscode
.
ExtensionContext
,
configuration
:
Configuration
,
reviewMode
:
ReviewM
anager
)
{
this
.
context
=
context
;
this
.
configuration
=
configuration
;
this
.
reviewMode
=
reviewMode
;
...
...
extensions/git-extended/src/review/fileChangesProvider.ts
0 → 100644
浏览文件 @
59ad3ecb
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
vscode
from
'
vscode
'
;
import
{
FileChangeTreeItem
}
from
'
../common/treeItems
'
;
import
{
Resource
}
from
'
../common/resources
'
;
export
class
FileChangesProvider
extends
vscode
.
Disposable
implements
vscode
.
TreeDataProvider
<
FileChangeTreeItem
>
{
private
_onDidChangeTreeData
=
new
vscode
.
EventEmitter
<
FileChangeTreeItem
>
();
readonly
onDidChangeTreeData
=
this
.
_onDidChangeTreeData
.
event
;
private
_localFileChanges
:
FileChangeTreeItem
[]
=
[];
constructor
(
private
context
:
vscode
.
ExtensionContext
)
{
super
(()
=>
this
.
dispose
());
this
.
context
.
subscriptions
.
push
(
vscode
.
window
.
registerTreeDataProvider
<
FileChangeTreeItem
>
(
'
prStatus
'
,
this
));
}
async
showPullRequestFileChanges
(
fileChanges
:
FileChangeTreeItem
[])
{
await
vscode
.
commands
.
executeCommand
(
'
setContext
'
,
'
git:ispr
'
,
true
);
this
.
_localFileChanges
=
fileChanges
;
this
.
_onDidChangeTreeData
.
fire
();
}
async
hide
()
{
await
vscode
.
commands
.
executeCommand
(
'
setContext
'
,
'
git:ispr
'
,
false
);
}
getTreeItem
(
element
:
FileChangeTreeItem
):
vscode
.
TreeItem
|
Thenable
<
vscode
.
TreeItem
>
{
if
(
element
.
comments
&&
element
.
comments
.
length
)
{
element
.
iconPath
=
Resource
.
icons
.
light
.
Comment
;
}
else
{
element
.
iconPath
=
Resource
.
getFileStatusUri
(
element
);
}
element
.
resourceUri
=
element
.
filePath
;
return
element
;
}
getChildren
(
element
?:
FileChangeTreeItem
):
vscode
.
ProviderResult
<
FileChangeTreeItem
[]
>
{
if
(
!
element
)
{
return
this
.
_localFileChanges
;
}
else
{
return
[];
}
}
}
\ No newline at end of file
extensions/git-extended/src/review/reviewM
ode
.ts
→
extensions/git-extended/src/review/reviewM
anager
.ts
浏览文件 @
59ad3ecb
...
...
@@ -15,6 +15,7 @@ import { PullRequestModel } from '../common/models/pullRequestModel';
import
{
toGitUri
}
from
'
../common/uri
'
;
import
{
GitChangeType
}
from
'
../common/models/file
'
;
import
{
PullRequestService
}
from
'
../services/pullRequestService
'
;
import
{
FileChangesProvider
}
from
'
./fileChangesProvider
'
;
const
REVIEW_STATE
=
'
git-extended.state
'
;
...
...
@@ -26,7 +27,7 @@ export interface ReviewState {
base
:
any
;
}
export
class
ReviewM
ode
implements
vscode
.
DecorationProvider
{
export
class
ReviewM
anager
implements
vscode
.
DecorationProvider
{
private
_documentCommentProvider
:
vscode
.
Disposable
;
private
_workspaceCommentProvider
:
vscode
.
Disposable
;
private
_command
:
vscode
.
Disposable
;
...
...
@@ -41,11 +42,22 @@ export class ReviewMode implements vscode.DecorationProvider {
private
_lastCommitSha
:
string
;
private
_onDidChangeCommentThreads
=
new
vscode
.
EventEmitter
<
vscode
.
CommentThreadChangedEvent
>
();
private
_prFileChangesProvider
:
FileChangesProvider
|
undefined
;
get
prFileChangesProvider
()
{
if
(
this
.
_prFileChangesProvider
===
undefined
)
{
this
.
_prFileChangesProvider
=
new
FileChangesProvider
(
this
.
_context
);
this
.
_disposables
.
push
(
this
.
_prFileChangesProvider
);
}
return
this
.
_prFileChangesProvider
;
}
constructor
(
private
_context
:
vscode
.
ExtensionContext
,
private
_repository
:
Repository
,
private
_pullRequestService
:
PullRequestService
,
private
_workspaceState
:
vscode
.
Memento
,
private
_gitRepo
:
any
private
_workspaceState
:
vscode
.
Memento
)
{
this
.
_documentCommentProvider
=
null
;
this
.
_workspaceCommentProvider
=
null
;
...
...
@@ -111,22 +123,7 @@ export class ReviewMode implements vscode.DecorationProvider {
}
await
this
.
getPullRequestData
(
pr
);
let
prChangeResources
:
vscode
.
SourceControlResourceState
[]
=
this
.
_localFileChanges
.
map
(
fileChange
=>
({
resourceUri
:
fileChange
.
filePath
,
command
:
{
title
:
'
show diff
'
,
command
:
'
vscode.diff
'
,
arguments
:
[
fileChange
.
parentFilePath
,
fileChange
.
filePath
,
fileChange
.
fileName
]
},
decorations
:
{
letter
:
fileChange
.
letter
}
}));
await
this
.
prFileChangesProvider
.
showPullRequestFileChanges
(
this
.
_localFileChanges
);
this
.
_command
=
vscode
.
commands
.
registerCommand
(
this
.
_prNumber
+
'
-post
'
,
async
(
uri
:
vscode
.
Uri
,
range
:
vscode
.
Range
,
thread
:
vscode
.
CommentThread
,
text
:
string
)
=>
{
try
{
...
...
@@ -174,10 +171,6 @@ export class ReviewMode implements vscode.DecorationProvider {
this
.
_onDidChangeDecorations
.
fire
();
this
.
registerCommentProvider
();
let
prGroup
:
vscode
.
SourceControlResourceGroup
=
this
.
_gitRepo
.
sourceControl
.
createResourceGroup
(
'
pr
'
,
'
Changes from PR
'
);
this
.
_resourceGroups
.
push
(
prGroup
);
prGroup
.
resourceStates
=
prChangeResources
;
}
private
async
updateComments
():
Promise
<
void
>
{
...
...
extensions/git/.vscode/launch.json
已删除
100644 → 0
浏览文件 @
9c5d1018
{
//
Use
IntelliSense
to
learn
about
possible
attributes.
//
Hover
to
view
descriptions
of
existing
attributes.
//
For
more
information
,
visit:
https://go.microsoft.com/fwlink/?linkid=
830387
"version"
:
"0.2.0"
,
"configurations"
:
[
{
"type"
:
"node"
,
"request"
:
"launch"
,
"name"
:
"Launch Program"
,
"program"
:
"${workspaceFolder}/out/main"
},
{
"name"
:
"Launch Extension"
,
"type"
:
"extensionHost"
,
"request"
:
"launch"
,
"runtimeExecutable"
:
"/Users/penlv/code/vscode/scripts/code.sh"
,
"args"
:
[
"--extensionDevelopmentPath=${workspaceFolder}"
],
"trace"
:
true
,
"protocol"
:
"inspector"
,
"stopOnEntry"
:
false
,
"sourceMaps"
:
true
,
"outFiles"
:
[
"${workspaceFolder}/out/**/*.js"
]
}
]
}
\ No newline at end of file
extensions/git/package.json
浏览文件 @
59ad3ecb
...
...
@@ -5,7 +5,7 @@
"publisher"
:
"vscode"
,
"version"
:
"1.0.0"
,
"engines"
:
{
"vscode"
:
"^1.
13
.0"
"vscode"
:
"^1.
5
.0"
},
"aiKey"
:
"AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217"
,
"enableProposedApi"
:
true
,
...
...
extensions/git/src/api.ts
浏览文件 @
59ad3ecb
...
...
@@ -7,7 +7,7 @@
import
{
Model
}
from
'
./model
'
;
import
{
Repository
as
ModelRepository
}
from
'
./repository
'
;
import
{
Uri
,
SourceControlInputBox
,
SourceControl
,
EventEmitter
,
Event
}
from
'
vscode
'
;
import
{
Uri
,
SourceControlInputBox
}
from
'
vscode
'
;
export
interface
InputBox
{
value
:
string
;
...
...
@@ -28,12 +28,10 @@ export class RepositoryImpl implements Repository {
readonly
rootUri
:
Uri
;
readonly
inputBox
:
InputBox
;
readonly
sourceControl
:
SourceControl
;
constructor
(
repository
:
ModelRepository
)
{
this
.
rootUri
=
Uri
.
file
(
repository
.
root
);
this
.
inputBox
=
new
InputBoxImpl
(
repository
.
inputBox
);
this
.
sourceControl
=
repository
.
sourceControl
;
}
}
...
...
@@ -43,16 +41,8 @@ export interface API {
}
export
class
APIImpl
implements
API
{
private
_onDidOpenRepository
=
new
EventEmitter
<
Repository
>
();
readonly
onDidOpenRepository
:
Event
<
Repository
>
=
this
.
_onDidOpenRepository
.
event
;
constructor
(
private
modelPromise
:
Promise
<
Model
>
)
{
modelPromise
.
then
(
model
=>
{
model
.
onDidOpenRepository
(
repository
=>
{
this
.
_onDidOpenRepository
.
fire
(
new
RepositoryImpl
(
repository
));
});
});
}
constructor
(
private
modelPromise
:
Promise
<
Model
>
)
{
}
async
getGitPath
():
Promise
<
string
>
{
const
model
=
await
this
.
modelPromise
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录