Skip to content

Commit

Permalink
Lack of feedback when searching for similar issues in extensions when…
Browse files Browse the repository at this point in the history
… reporting an issue on an extension, fixes #50656
  • Loading branch information
Rachel Macfarlane committed Jun 7, 2018
1 parent 4f324d1 commit e0e1163
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
37 changes: 27 additions & 10 deletions src/vs/code/electron-browser/issue/issueReporterMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
import { ILogService, getLogLevel } from 'vs/platform/log/common/log';
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
import { normalizeGitHubIssuesUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { normalizeGitHubUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { Button } from 'vs/base/browser/ui/button/button';

const MAX_URL_LENGTH = platform.isWindows ? 2081 : 5400;
Expand Down Expand Up @@ -466,13 +466,20 @@ export class IssueReporter extends Disposable {
}

private searchExtensionIssues(title: string): void {
const url = this.getExtensionRepositoryUrl();
const url = this.getExtensionGitHubUrl();
if (title) {
const matches = /^https?:\/\/github\.com\/(.*)(?:.git)/.exec(url);
const matches = /^https?:\/\/github\.com\/(.*)/.exec(url);
if (matches && matches.length) {
const repo = matches[1];
return this.searchGitHub(repo, title);
}

// If the extension has no repository, display empty search results
if (this.issueReporterModel.getData().selectedExtension) {
this.clearSearchResults();
return this.displaySearchResults([]);

}
}

this.clearSearchResults();
Expand Down Expand Up @@ -771,16 +778,26 @@ export class IssueReporter extends Disposable {
return true;
}

private getExtensionGitHubUrl(): string {
let repositoryUrl = '';
const bugsUrl = this.getExtensionBugsUrl();
const extensionUrl = this.getExtensionRepositoryUrl();
// If given, try to match the extension's bug url
if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubUrl(bugsUrl);
} else if (extensionUrl && extensionUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubUrl(extensionUrl);
}

return repositoryUrl;
}

private getIssueUrlWithTitle(issueTitle: string): string {
let repositoryUrl = product.reportIssueUrl;
if (this.issueReporterModel.fileOnExtension()) {
const bugsUrl = this.getExtensionBugsUrl();
const extensionUrl = this.getExtensionRepositoryUrl();
// If given, try to match the extension's bug url
if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubIssuesUrl(bugsUrl);
} else if (extensionUrl && extensionUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubIssuesUrl(extensionUrl);
const extensionGitHubUrl = this.getExtensionGitHubUrl();
if (extensionGitHubUrl) {
repositoryUrl = extensionGitHubUrl + '/issues/new';
}
}

Expand Down
14 changes: 6 additions & 8 deletions src/vs/code/electron-browser/issue/issueReporterUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { endsWith, rtrim } from 'vs/base/common/strings';

export function normalizeGitHubIssuesUrl(url: string): string {
export function normalizeGitHubUrl(url: string): string {
// If the url has a .git suffix, remove it
if (endsWith(url, '.git')) {
url = url.substr(0, url.length - 4);
Expand All @@ -16,15 +16,13 @@ export function normalizeGitHubIssuesUrl(url: string): string {
// Remove trailing slash
url = rtrim(url, '/');

// If the url already ends with issues/new, it's beautiful, return it
if (endsWith(url, 'issues/new')) {
return url;
if (endsWith(url, '/new')) {
url = rtrim(url, '/new');
}

// Add new segment if it does not exist
if (endsWith(url, 'issues')) {
return url + '/new';
if (endsWith(url, '/issues')) {
url = rtrim(url, '/issues');
}

return url + '/issues/new';
return url;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import * as assert from 'assert';
import { IssueReporterModel } from 'vs/code/electron-browser/issue/issueReporterModel';
import { normalizeGitHubIssuesUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { normalizeGitHubUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { IssueType } from 'vs/platform/issue/common/issue';

suite('IssueReporter', () => {
Expand Down Expand Up @@ -79,7 +79,7 @@ OS version: undefined
'https://github.com/repo/issues/new',
'https://github.com/repo/issues/new/'
].forEach(url => {
assert.equal('https://github.com/repo/issues/new', normalizeGitHubIssuesUrl(url));
assert.equal('https://github.com/repo', normalizeGitHubUrl(url));
});
});

Expand Down

0 comments on commit e0e1163

Please sign in to comment.