Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
c05e57d9
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c05e57d9
编写于
3月 26, 2018
作者:
R
Rachel Macfarlane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Search for similar issues for extensions in issue reporter
上级
af9dc731
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
83 addition
and
15 deletion
+83
-15
src/vs/code/electron-browser/issue/issueReporterMain.ts
src/vs/code/electron-browser/issue/issueReporterMain.ts
+83
-15
未找到文件。
src/vs/code/electron-browser/issue/issueReporterMain.ts
浏览文件 @
c05e57d9
...
...
@@ -69,6 +69,7 @@ export class IssueReporter extends Disposable {
private
numberOfSearchResultsDisplayed
=
0
;
private
receivedSystemInfo
=
false
;
private
receivedPerformanceInfo
=
false
;
private
shouldQueueSearch
=
false
;
constructor
(
configuration
:
IssueReporterConfiguration
)
{
super
();
...
...
@@ -324,15 +325,28 @@ export class IssueReporter extends Disposable {
this
.
addEventListener
(
'
issue-source
'
,
'
change
'
,
(
event
:
Event
)
=>
{
const
fileOnExtension
=
JSON
.
parse
((
<
HTMLInputElement
>
event
.
target
).
value
);
this
.
issueReporterModel
.
update
({
fileOnExtension
:
fileOnExtension
,
includeExtensions
:
!
fileOnExtension
});
this
.
issueReporterModel
.
update
({
fileOnExtension
:
fileOnExtension
,
includeExtensions
:
!
fileOnExtension
,
selectedExtension
:
null
});
this
.
render
();
this
.
search
();
const
title
=
(
<
HTMLInputElement
>
document
.
getElementById
(
'
issue-title
'
)).
value
;
if
(
fileOnExtension
)
{
this
.
searchExtensionIssues
(
title
);
}
else
{
const
description
=
this
.
issueReporterModel
.
getData
().
issueDescription
;
this
.
searchVSCodeIssues
(
title
,
description
);
}
});
this
.
addEventListener
(
'
description
'
,
'
input
'
,
(
event
:
Event
)
=>
{
const
issueDescription
=
(
<
HTMLInputElement
>
event
.
target
).
value
;
this
.
issueReporterModel
.
update
({
issueDescription
});
this
.
search
();
// Only search for extension issues on title change
const
fileOnExtension
=
this
.
issueReporterModel
.
getData
().
fileOnExtension
;
if
(
!
fileOnExtension
)
{
const
title
=
(
<
HTMLInputElement
>
document
.
getElementById
(
'
issue-title
'
)).
value
;
this
.
searchVSCodeIssues
(
title
,
issueDescription
);
}
});
this
.
addEventListener
(
'
issue-title
'
,
'
input
'
,
(
e
)
=>
{
...
...
@@ -344,7 +358,13 @@ export class IssueReporter extends Disposable {
hide
(
lengthValidationMessage
);
}
this
.
search
();
const
fileOnExtension
=
this
.
issueReporterModel
.
getData
().
fileOnExtension
;
if
(
fileOnExtension
)
{
this
.
searchExtensionIssues
(
title
);
}
else
{
const
description
=
this
.
issueReporterModel
.
getData
().
issueDescription
;
this
.
searchVSCodeIssues
(
title
,
description
);
}
});
this
.
addEventListener
(
'
github-submit-btn
'
,
'
click
'
,
()
=>
this
.
createIssue
());
...
...
@@ -415,16 +435,12 @@ export class IssueReporter extends Disposable {
return
false
;
}
private
search
():
void
{
// Only search issues in VSCode for now.
const
fileOnExtension
=
this
.
issueReporterModel
.
getData
().
fileOnExtension
;
if
(
fileOnExtension
)
{
this
.
clearSearchResults
();
return
;
}
private
getExtensionRepositoryUrl
():
string
{
const
selectedExtension
=
this
.
issueReporterModel
.
getData
().
selectedExtension
;
return
selectedExtension
&&
selectedExtension
.
manifest
&&
selectedExtension
.
manifest
.
repository
&&
selectedExtension
.
manifest
.
repository
.
url
;
}
const
title
=
(
<
HTMLInputElement
>
document
.
getElementById
(
'
issue-title
'
)).
value
;
const
issueDescription
=
(
<
HTMLInputElement
>
document
.
getElementById
(
'
description
'
)).
value
;
private
searchVSCodeIssues
(
title
:
string
,
issueDescription
:
string
):
void
{
if
(
title
||
issueDescription
)
{
this
.
searchDuplicates
(
title
,
issueDescription
);
}
else
{
...
...
@@ -432,12 +448,59 @@ export class IssueReporter extends Disposable {
}
}
private
searchExtensionIssues
(
title
:
string
):
void
{
const
url
=
this
.
getExtensionRepositoryUrl
();
if
(
title
)
{
const
matches
=
/^https
?
:
\/\/
github
\.
com
\/(
.*
)(?:
.git
)
/
.
exec
(
url
);
if
(
matches
&&
matches
.
length
)
{
const
repo
=
matches
[
1
];
return
this
.
searchGitHub
(
repo
,
title
);
}
}
this
.
clearSearchResults
();
}
private
clearSearchResults
():
void
{
const
similarIssues
=
document
.
getElementById
(
'
similar-issues
'
);
similarIssues
.
innerHTML
=
''
;
this
.
numberOfSearchResultsDisplayed
=
0
;
}
@
debounce
(
300
)
private
searchGitHub
(
repo
:
string
,
title
:
string
):
void
{
const
query
=
`is:issue+repo:
${
repo
}
+
${
title
}
`
;
const
similarIssues
=
document
.
getElementById
(
'
similar-issues
'
);
window
.
fetch
(
`https://api.github.com/search/issues?q=
${
query
}
`
).
then
((
response
)
=>
{
response
.
json
().
then
(
result
=>
{
similarIssues
.
innerHTML
=
''
;
if
(
result
&&
result
.
items
)
{
this
.
displaySearchResults
(
result
.
items
);
}
else
{
// If the items property isn't present, the rate limit has been hit
const
message
=
$
(
'
div.list-title
'
);
message
.
textContent
=
localize
(
'
rateLimited
'
,
"
GitHub query limit exceeded. Please wait.
"
);
similarIssues
.
appendChild
(
message
);
const
resetTime
=
response
.
headers
.
get
(
'
X-RateLimit-Reset
'
);
const
timeToWait
=
parseInt
(
resetTime
)
-
Math
.
floor
(
Date
.
now
()
/
1000
);
if
(
this
.
shouldQueueSearch
)
{
this
.
shouldQueueSearch
=
false
;
setTimeout
(()
=>
{
this
.
searchGitHub
(
repo
,
title
);
this
.
shouldQueueSearch
=
true
;
},
timeToWait
*
1000
);
}
}
}).
catch
(
e
=>
{
this
.
logSearchError
(
e
);
});
}).
catch
(
e
=>
{
this
.
logSearchError
(
e
);
});
}
@
debounce
(
300
)
private
searchDuplicates
(
title
:
string
,
body
:
string
):
void
{
const
url
=
'
https://vscode-probot.westus.cloudapp.azure.com:7890/duplicate_candidates
'
;
...
...
@@ -679,8 +742,7 @@ export class IssueReporter extends Disposable {
private
getIssueUrlWithTitle
(
issueTitle
:
string
):
string
{
let
repositoryUrl
=
product
.
reportIssueUrl
;
if
(
this
.
issueReporterModel
.
getData
().
fileOnExtension
)
{
const
selectedExtension
=
this
.
issueReporterModel
.
getData
().
selectedExtension
;
const
extensionUrl
=
selectedExtension
&&
selectedExtension
.
manifest
&&
selectedExtension
.
manifest
.
repository
&&
selectedExtension
.
manifest
.
repository
.
url
;
const
extensionUrl
=
this
.
getExtensionRepositoryUrl
();
if
(
extensionUrl
)
{
// Remove '.git' suffix
repositoryUrl
=
`
${
extensionUrl
.
indexOf
(
'
.git
'
)
!==
-
1
?
extensionUrl
.
substr
(
0
,
extensionUrl
.
length
-
4
)
:
extensionUrl
}
/issues/new/`
;
...
...
@@ -715,6 +777,12 @@ export class IssueReporter extends Disposable {
const
matches
=
extensions
.
filter
(
extension
=>
extension
.
identifier
.
id
===
selectedExtensionId
);
if
(
matches
.
length
)
{
this
.
issueReporterModel
.
update
({
selectedExtension
:
matches
[
0
]
});
const
title
=
(
<
HTMLInputElement
>
document
.
getElementById
(
'
issue-title
'
)).
value
;
this
.
searchExtensionIssues
(
title
);
}
else
{
this
.
issueReporterModel
.
update
({
selectedExtension
:
null
});
this
.
clearSearchResults
();
}
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录