Enables typescript strict mode

Fixes all the compile/lint issues
This commit is contained in:
Eric Amodio
2017-05-11 02:14:58 -04:00
parent 90245b1111
commit ee29596d45
52 changed files with 525 additions and 461 deletions

View File

@@ -54,8 +54,8 @@ export class Git {
return git;
}
static async getRepoPath(cwd: string) {
if (!cwd) return '';
static async getRepoPath(cwd: string | undefined) {
if (cwd === undefined) return '';
const data = await gitCommand(cwd, 'rev-parse', '--show-toplevel');
if (!data) return '';
@@ -63,7 +63,7 @@ export class Git {
return data.replace(/\r?\n|\r/g, '').replace(/\\/g, '/');
}
static async getVersionedFile(repoPath: string, fileName: string, branchOrSha: string) {
static async getVersionedFile(repoPath: string | undefined, fileName: string, branchOrSha: string) {
const data = await Git.show(repoPath, fileName, branchOrSha);
const suffix = Git.isSha(branchOrSha) ? branchOrSha.substring(0, 8) : branchOrSha;
@@ -112,7 +112,7 @@ export class Git {
}
}
else {
repoPath = this.normalizePath(extract ? path.dirname(fileName) : repoPath);
repoPath = this.normalizePath(extract ? path.dirname(fileName) : repoPath!);
fileName = this.normalizePath(extract ? path.basename(fileName) : fileName);
}
@@ -126,7 +126,7 @@ export class Git {
// Git commands
static blame(repoPath: string, fileName: string, sha?: string, startLine?: number, endLine?: number) {
static blame(repoPath: string | undefined, fileName: string, sha?: string, startLine?: number, endLine?: number) {
const [file, root] = Git.splitPath(fileName, repoPath);
const params = [`blame`, `--root`, `--incremental`];
@@ -208,7 +208,7 @@ export class Git {
}
// If we are looking for a specific sha don't exclude merge commits
if (!sha || maxCount > 2) {
if (!sha || maxCount! > 2) {
params.push(`--no-merges`);
}
else {
@@ -236,7 +236,7 @@ export class Git {
return gitCommand(root, ...params);
}
static log_search(repoPath: string, search?: string[], maxCount?: number) {
static log_search(repoPath: string, search: string[] = [], maxCount?: number) {
const params = [...defaultLogParams, `-m`, `-i`];
if (maxCount) {
params.push(`-n${maxCount}`);
@@ -262,7 +262,7 @@ export class Git {
return gitCommand(repoPath, 'remote', 'get-url', remote);
}
static show(repoPath: string, fileName: string, branchOrSha: string) {
static show(repoPath: string | undefined, fileName: string, branchOrSha: string) {
const [file, root] = Git.splitPath(fileName, repoPath);
branchOrSha = branchOrSha.replace('^', '');

View File

@@ -7,7 +7,7 @@ import { Logger } from '../logger';
export interface BlameabilityChangeEvent {
blameable: boolean;
editor: TextEditor;
editor: TextEditor | undefined;
}
export class GitContextTracker extends Disposable {
@@ -18,8 +18,8 @@ export class GitContextTracker extends Disposable {
}
private _disposable: Disposable;
private _documentChangeDisposable: Disposable;
private _editor: TextEditor;
private _documentChangeDisposable: Disposable | undefined;
private _editor: TextEditor | undefined;
private _gitEnabled: boolean;
private _isBlameable: boolean;
@@ -47,7 +47,7 @@ export class GitContextTracker extends Disposable {
}
_onConfigurationChanged() {
const gitEnabled = workspace.getConfiguration('git').get<boolean>('enabled');
const gitEnabled = workspace.getConfiguration('git').get<boolean>('enabled', true);
if (this._gitEnabled !== gitEnabled) {
this._gitEnabled = gitEnabled;
setCommandContext(CommandContext.Enabled, gitEnabled);
@@ -55,9 +55,9 @@ export class GitContextTracker extends Disposable {
}
}
private _onActiveTextEditorChanged(editor: TextEditor) {
private _onActiveTextEditorChanged(editor: TextEditor | undefined) {
this._editor = editor;
this._updateContext(this._gitEnabled && editor);
this._updateContext(this._gitEnabled ? editor : undefined);
this._subscribeToDocumentChanges();
}
@@ -97,9 +97,9 @@ export class GitContextTracker extends Disposable {
this._documentChangeDisposable = undefined;
}
private async _updateContext(editor: TextEditor) {
private async _updateContext(editor: TextEditor | undefined) {
try {
const gitUri = editor && await GitUri.fromUri(editor.document.uri, this.git);
const gitUri = editor === undefined ? undefined : await GitUri.fromUri(editor.document.uri, this.git);
await Promise.all([
this._updateEditorContext(gitUri, editor),
@@ -131,12 +131,12 @@ export class GitContextTracker extends Disposable {
private async _updateEditorContext(uri: GitUri | undefined, editor: TextEditor | undefined) {
try {
const tracked = uri && await this.git.isTracked(uri);
const tracked = uri === undefined ? false : await this.git.isTracked(uri);
setCommandContext(CommandContext.IsTracked, tracked);
let blameable = tracked && editor && editor.document && !editor.document.isDirty;
let blameable = tracked && (editor !== undefined && editor.document !== undefined && !editor.document.isDirty);
if (blameable) {
blameable = await this.git.getBlameability(uri);
blameable = uri === undefined ? false : await this.git.getBlameability(uri);
}
this._updateBlameability(blameable, true);

View File

@@ -43,7 +43,7 @@ export class GitUri extends Uri {
const commit = commitOrRepoPath;
base._fsPath = path.resolve(commit.repoPath, commit.originalFileName || commit.fileName);
if (!GitService.isUncommitted(commit.sha)) {
if (commit.sha !== undefined && !GitService.isUncommitted(commit.sha)) {
this.sha = commit.sha;
this.repoPath = commit.repoPath;
}
@@ -72,7 +72,7 @@ export class GitUri extends Uri {
}
getRelativePath(): string {
return GitService.normalizePath(path.relative(this.repoPath, this.fsPath));
return GitService.normalizePath(path.relative(this.repoPath || '', this.fsPath));
}
static async fromUri(uri: Uri, git: GitService) {

View File

@@ -13,7 +13,7 @@ export interface IGitCommit {
repoPath: string;
sha: string;
fileName: string;
author: string;
author?: string;
date: Date;
message: string;
lines: IGitCommitLine[];

View File

@@ -1,66 +1,66 @@
'use strict';
import { Uri } from 'vscode';
import { GitCommit, GitCommitType, IGitCommitLine } from './commit';
import { IGitStatusFile, GitStatusFileStatus } from './status';
import * as path from 'path';
export class GitLogCommit extends GitCommit {
fileNames: string;
fileStatuses: IGitStatusFile[];
nextSha?: string;
nextFileName?: string;
parentShas: string[];
status?: GitStatusFileStatus;
constructor(
type: GitCommitType,
repoPath: string,
sha: string,
fileName: string,
author: string,
date: Date,
message: string,
status?: GitStatusFileStatus,
fileStatuses?: IGitStatusFile[],
lines?: IGitCommitLine[],
originalFileName?: string,
previousSha?: string,
previousFileName?: string
) {
super(type, repoPath, sha, fileName, author, date, message, lines, originalFileName, previousSha, previousFileName);
this.fileNames = this.fileName;
if (fileStatuses) {
this.fileStatuses = fileStatuses.filter(_ => !!_.fileName);
const fileStatus = this.fileStatuses[0];
this.fileName = fileStatus.fileName;
this.status = fileStatus.status;
}
else {
this.fileStatuses = [{ status: status, fileName: fileName, originalFileName: originalFileName }];
this.status = status;
}
}
get isMerge() {
return this.parentShas && this.parentShas.length > 1;
}
get nextShortSha() {
return this.nextSha && this.nextSha.substring(0, 8);
}
get nextUri(): Uri {
return this.nextFileName ? Uri.file(path.resolve(this.repoPath, this.nextFileName)) : this.uri;
}
getDiffStatus(): string {
const added = this.fileStatuses.filter(_ => _.status === 'A' || _.status === '?').length;
const deleted = this.fileStatuses.filter(_ => _.status === 'D').length;
const changed = this.fileStatuses.filter(_ => _.status !== 'A' && _.status !== '?' && _.status !== 'D').length;
return `+${added} ~${changed} -${deleted}`;
}
'use strict';
import { Uri } from 'vscode';
import { GitCommit, GitCommitType, IGitCommitLine } from './commit';
import { IGitStatusFile, GitStatusFileStatus } from './status';
import * as path from 'path';
export class GitLogCommit extends GitCommit {
fileNames: string;
fileStatuses: IGitStatusFile[];
nextSha?: string;
nextFileName?: string;
parentShas: string[];
status?: GitStatusFileStatus;
constructor(
type: GitCommitType,
repoPath: string,
sha: string,
fileName: string,
author: string,
date: Date,
message: string,
status?: GitStatusFileStatus,
fileStatuses?: IGitStatusFile[],
lines?: IGitCommitLine[],
originalFileName?: string,
previousSha?: string,
previousFileName?: string
) {
super(type, repoPath, sha, fileName, author, date, message, lines, originalFileName, previousSha, previousFileName);
this.fileNames = this.fileName;
if (fileStatuses) {
this.fileStatuses = fileStatuses.filter(_ => !!_.fileName);
const fileStatus = this.fileStatuses[0];
this.fileName = fileStatus.fileName;
this.status = fileStatus.status;
}
else {
this.fileStatuses = [{ status: status, fileName: fileName, originalFileName: originalFileName } as IGitStatusFile];
this.status = status;
}
}
get isMerge() {
return this.parentShas && this.parentShas.length > 1;
}
get nextShortSha() {
return this.nextSha && this.nextSha.substring(0, 8);
}
get nextUri(): Uri {
return this.nextFileName ? Uri.file(path.resolve(this.repoPath, this.nextFileName)) : this.uri;
}
getDiffStatus(): string {
const added = this.fileStatuses.filter(_ => _.status === 'A' || _.status === '?').length;
const deleted = this.fileStatuses.filter(_ => _.status === 'D').length;
const changed = this.fileStatuses.filter(_ => _.status !== 'A' && _.status !== '?' && _.status !== 'D').length;
return `+${added} ~${changed} -${deleted}`;
}
}

View File

@@ -19,7 +19,7 @@ export class GitStashCommit extends GitLogCommit {
previousSha?: string,
previousFileName?: string
) {
super('stash', repoPath, sha, fileName, undefined, date, message, status, fileStatuses, lines, originalFileName, previousSha, previousFileName);
super('stash', repoPath, sha, fileName, 'You', date, message, status, fileStatuses, lines, originalFileName, previousSha, previousFileName);
}
get shortSha() {

View File

@@ -10,7 +10,7 @@ interface IBlameEntry {
originalLine: number;
lineCount: number;
author?: string;
author: string;
// authorEmail?: string;
authorDate?: string;
authorTimeZone?: string;
@@ -30,7 +30,7 @@ interface IBlameEntry {
export class GitBlameParser {
private static _parseEntries(data: string): IBlameEntry[] {
private static _parseEntries(data: string): IBlameEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
@@ -38,7 +38,7 @@ export class GitBlameParser {
const entries: IBlameEntry[] = [];
let entry: IBlameEntry;
let entry: IBlameEntry | undefined = undefined;
let position = -1;
while (++position < lines.length) {
let lineParts = lines[position].split(' ');
@@ -46,13 +46,13 @@ export class GitBlameParser {
continue;
}
if (!entry) {
if (entry === undefined) {
entry = {
sha: lineParts[0],
originalLine: parseInt(lineParts[1], 10) - 1,
line: parseInt(lineParts[2], 10) - 1,
lineCount: parseInt(lineParts[3], 10)
};
} as IBlameEntry;
continue;
}
@@ -116,7 +116,7 @@ export class GitBlameParser {
return entries;
}
static parse(data: string, repoPath: string, fileName: string): IGitBlame {
static parse(data: string, repoPath: string | undefined, fileName: string): IGitBlame | undefined {
const entries = this._parseEntries(data);
if (!entries) return undefined;
@@ -129,24 +129,26 @@ export class GitBlameParser {
for (let i = 0, len = entries.length; i < len; i++) {
const entry = entries[i];
if (i === 0 && !repoPath) {
if (i === 0 && repoPath === undefined) {
// Try to get the repoPath from the most recent commit
repoPath = Git.normalizePath(fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName, ''));
repoPath = Git.normalizePath(fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName!, ''));
relativeFileName = Git.normalizePath(path.relative(repoPath, fileName));
}
let commit = commits.get(entry.sha);
if (!commit) {
let author = authors.get(entry.author);
if (!author) {
author = {
name: entry.author,
lineCount: 0
};
authors.set(entry.author, author);
if (commit === undefined) {
if (entry.author !== undefined) {
let author = authors.get(entry.author);
if (author === undefined) {
author = {
name: entry.author,
lineCount: 0
};
authors.set(entry.author, author);
}
}
commit = new GitCommit('blame', repoPath, entry.sha, relativeFileName, entry.author, moment(`${entry.authorDate} ${entry.authorTimeZone}`, 'X +-HHmm').toDate(), entry.summary);
commit = new GitCommit('blame', repoPath!, entry.sha, relativeFileName!, entry.author, moment(`${entry.authorDate} ${entry.authorTimeZone}`, 'X +-HHmm').toDate(), entry.summary!);
if (relativeFileName !== entry.fileName) {
commit.originalFileName = entry.fileName;
@@ -176,7 +178,14 @@ export class GitBlameParser {
}
}
commits.forEach(c => authors.get(c.author).lineCount += c.lines.length);
commits.forEach(c => {
if (c.author === undefined) return;
const author = authors.get(c.author);
if (author === undefined) return;
author.lineCount += c.lines.length;
});
const sortedAuthors: Map<string, IGitAuthor> = new Map();
// const values =

View File

@@ -8,7 +8,7 @@ import * as path from 'path';
interface ILogEntry {
sha: string;
author?: string;
author: string;
authorDate?: string;
// committer?: string;
@@ -29,7 +29,7 @@ const diffRegex = /diff --git a\/(.*) b\/(.*)/;
export class GitLogParser {
private static _parseEntries(data: string, type: GitCommitType, maxCount: number | undefined, reverse: boolean): ILogEntry[] {
private static _parseEntries(data: string, type: GitCommitType, maxCount: number | undefined, reverse: boolean): ILogEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
@@ -37,7 +37,7 @@ export class GitLogParser {
const entries: ILogEntry[] = [];
let entry: ILogEntry;
let entry: ILogEntry | undefined = undefined;
let position = -1;
while (++position < lines.length) {
// Since log --reverse doesn't properly honor a max count -- enforce it here
@@ -48,12 +48,12 @@ export class GitLogParser {
continue;
}
if (!entry) {
if (entry === undefined) {
if (!Git.shaRegex.test(lineParts[0])) continue;
entry = {
sha: lineParts[0]
};
} as ILogEntry;
continue;
}
@@ -118,10 +118,12 @@ export class GitLogParser {
if (lineParts[0] === 'diff') {
diff = true;
const matches = diffRegex.exec(line);
entry.fileName = matches[1];
const originalFileName = matches[2];
if (entry.fileName !== originalFileName) {
entry.originalFileName = originalFileName;
if (matches != null) {
entry.fileName = matches[1];
const originalFileName = matches[2];
if (entry.fileName !== originalFileName) {
entry.originalFileName = originalFileName;
}
}
continue;
}
@@ -133,7 +135,7 @@ export class GitLogParser {
const status = {
status: line[0] as GitStatusFileStatus,
fileName: line.substring(1),
originalFileName: undefined as string
originalFileName: undefined
} as IGitStatusFile;
this._parseFileName(status);
@@ -164,7 +166,7 @@ export class GitLogParser {
return entries;
}
static parse(data: string, type: GitCommitType, repoPath: string | undefined, fileName: string | undefined, sha: string | undefined, maxCount: number | undefined, reverse: boolean, range: Range): IGitLog {
static parse(data: string, type: GitCommitType, repoPath: string | undefined, fileName: string | undefined, sha: string | undefined, maxCount: number | undefined, reverse: boolean, range: Range | undefined): IGitLog | undefined {
const entries = this._parseEntries(data, type, maxCount, reverse);
if (!entries) return undefined;
@@ -172,7 +174,7 @@ export class GitLogParser {
const commits: Map<string, GitLogCommit> = new Map();
let relativeFileName: string;
let recentCommit: GitLogCommit;
let recentCommit: GitLogCommit | undefined = undefined;
if (repoPath !== undefined) {
repoPath = Git.normalizePath(repoPath);
@@ -184,28 +186,30 @@ export class GitLogParser {
const entry = entries[i];
if (i === 0 && type === 'file' && !repoPath) {
if (i === 0 && repoPath === undefined && type === 'file' && fileName !== undefined) {
// Try to get the repoPath from the most recent commit
repoPath = Git.normalizePath(fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName, ''));
repoPath = Git.normalizePath(fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName!, ''));
relativeFileName = Git.normalizePath(path.relative(repoPath, fileName));
}
else {
relativeFileName = entry.fileName;
relativeFileName = entry.fileName!;
}
let commit = commits.get(entry.sha);
if (!commit) {
let author = authors.get(entry.author);
if (!author) {
author = {
name: entry.author,
lineCount: 0
};
authors.set(entry.author, author);
if (commit === undefined) {
if (entry.author !== undefined) {
let author = authors.get(entry.author);
if (author === undefined) {
author = {
name: entry.author,
lineCount: 0
};
authors.set(entry.author, author);
}
}
commit = new GitLogCommit(type, repoPath, entry.sha, relativeFileName, entry.author, moment(entry.authorDate).toDate(), entry.summary, entry.status, entry.fileStatuses, undefined, entry.originalFileName);
commit.parentShas = entry.parentShas;
commit = new GitLogCommit(type, repoPath!, entry.sha, relativeFileName, entry.author, moment(entry.authorDate).toDate(), entry.summary!, entry.status, entry.fileStatuses, undefined, entry.originalFileName);
commit.parentShas = entry.parentShas!;
if (relativeFileName !== entry.fileName) {
commit.originalFileName = entry.fileName;
@@ -217,7 +221,7 @@ export class GitLogParser {
// Logger.log(`merge commit? ${entry.sha}`);
// }
if (recentCommit) {
if (recentCommit !== undefined) {
recentCommit.previousSha = commit.sha;
// If the commit sha's match (merge commit), just forward it along
@@ -232,7 +236,14 @@ export class GitLogParser {
recentCommit = commit;
}
commits.forEach(c => authors.get(c.author).lineCount += c.lines.length);
commits.forEach(c => {
if (c.author === undefined) return;
const author = authors.get(c.author);
if (author === undefined) return;
author.lineCount += c.lines.length;
});
const sortedAuthors: Map<string, IGitAuthor> = new Map();
// const values =
@@ -258,10 +269,12 @@ export class GitLogParser {
}
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {
if (entry.fileName === undefined) return;
const index = entry.fileName.indexOf('\t') + 1;
if (index) {
if (index > 0) {
const next = entry.fileName.indexOf('\t', index) + 1;
if (next) {
if (next > 0) {
entry.originalFileName = entry.fileName.substring(index, next - 1);
entry.fileName = entry.fileName.substring(next);
}

View File

@@ -6,15 +6,15 @@ import * as moment from 'moment';
interface IStashEntry {
sha: string;
date?: string;
fileNames?: string;
fileNames: string;
fileStatuses?: IGitStatusFile[];
summary?: string;
stashName?: string;
summary: string;
stashName: string;
}
export class GitStashParser {
private static _parseEntries(data: string): IStashEntry[] {
private static _parseEntries(data: string): IStashEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
@@ -22,7 +22,7 @@ export class GitStashParser {
const entries: IStashEntry[] = [];
let entry: IStashEntry;
let entry: IStashEntry | undefined = undefined;
let position = -1;
while (++position < lines.length) {
let lineParts = lines[position].split(' ');
@@ -30,12 +30,12 @@ export class GitStashParser {
continue;
}
if (!entry) {
if (entry === undefined) {
if (!Git.shaRegex.test(lineParts[0])) continue;
entry = {
sha: lineParts[0]
};
} as IStashEntry;
continue;
}
@@ -86,7 +86,7 @@ export class GitStashParser {
const status = {
status: line[0] as GitStatusFileStatus,
fileName: line.substring(1),
originalFileName: undefined as string
originalFileName: undefined
} as IGitStatusFile;
this._parseFileName(status);
@@ -109,9 +109,9 @@ export class GitStashParser {
return entries;
}
static parse(data: string, repoPath: string): IGitStash {
static parse(data: string, repoPath: string): IGitStash | undefined {
const entries = this._parseEntries(data);
if (!entries) return undefined;
if (entries === undefined) return undefined;
const commits: Map<string, GitStashCommit> = new Map();
@@ -119,8 +119,8 @@ export class GitStashParser {
const entry = entries[i];
let commit = commits.get(entry.sha);
if (!commit) {
commit = new GitStashCommit(entry.stashName, repoPath, entry.sha, entry.fileNames, moment(entry.date).toDate(), entry.summary, undefined, entry.fileStatuses);
if (commit !== undefined) {
commit = new GitStashCommit(entry.stashName, repoPath, entry.sha, entry.fileNames, moment(entry.date).toDate(), entry.summary, undefined, entry.fileStatuses) as GitStashCommit;
commits.set(entry.sha, commit);
}
}
@@ -132,10 +132,12 @@ export class GitStashParser {
}
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {
if (entry.fileName === undefined) return;
const index = entry.fileName.indexOf('\t') + 1;
if (index) {
if (index > 0) {
const next = entry.fileName.indexOf('\t', index) + 1;
if (next) {
if (next > 0) {
entry.originalFileName = entry.fileName.substring(index, next - 1);
entry.fileName = entry.fileName.substring(next);
}

View File

@@ -13,20 +13,22 @@ const behindStatusV1Regex = /(?:behind ([0-9]+))/;
export class GitStatusParser {
static parse(data: string, repoPath: string, porcelainVersion: number): IGitStatus {
static parse(data: string, repoPath: string, porcelainVersion: number): IGitStatus | undefined {
if (!data) return undefined;
const lines = data.split('\n').filter(_ => !!_);
if (!lines.length) return undefined;
const status = {
branch: '',
repoPath: Git.normalizePath(repoPath),
sha: '',
state: {
ahead: 0,
behind: 0
},
files: []
} as IGitStatus;
};
if (porcelainVersion >= 2) {
this._parseV2(lines, repoPath, status);
@@ -50,10 +52,10 @@ export class GitStatusParser {
const upstreamStatus = lineParts.slice(2).join(' ');
const aheadStatus = aheadStatusV1Regex.exec(upstreamStatus);
status.state.ahead = +aheadStatus[1] || 0;
status.state.ahead = aheadStatus == null ? 0 : +aheadStatus[1] || 0;
const behindStatus = behindStatusV1Regex.exec(upstreamStatus);
status.state.behind = +behindStatus[1] || 0;
status.state.behind = behindStatus == null ? 0 : +behindStatus[1] || 0;
}
}
else {
@@ -97,7 +99,7 @@ export class GitStatusParser {
}
else {
let lineParts = line.split(' ');
let entry: IFileStatusEntry;
let entry: IFileStatusEntry | undefined = undefined;
switch (lineParts[0][0]) {
case '1': // normal
entry = this._parseFileEntry(lineParts[1], lineParts.slice(8).join(' '));
@@ -114,7 +116,7 @@ export class GitStatusParser {
break;
}
if (entry) {
if (entry !== undefined) {
status.files.push(new GitStatusFile(repoPath, entry.status, entry.fileName, entry.staged, entry.originalFileName));
}
}
@@ -130,6 +132,6 @@ export class GitStatusParser {
fileName: fileName,
originalFileName: originalFileName,
staged: !!indexStatus
};
} as IFileStatusEntry;
}
}

View File

@@ -19,9 +19,11 @@ const UrlRegex = /^(?:git:\/\/(.*?)\/|https:\/\/(.*?)\/|http:\/\/(.*?)\/|git@(.*
export class RemoteProviderFactory {
static getRemoteProvider(url: string): RemoteProvider {
static getRemoteProvider(url: string): RemoteProvider | undefined {
try {
const match = UrlRegex.exec(url);
if (match == null) return undefined;
const domain = match[1] || match[2] || match[3] || match[4] || match[5];
const path = match[6].replace(/\.git/, '');

View File

@@ -26,10 +26,12 @@ export abstract class RemoteProvider {
protected abstract getUrlForBranch(branch: string): string;
protected abstract getUrlForCommit(sha: string): string;
protected abstract getUrlForFile(fileName: string, branch: string, sha?: string, range?: Range): string;
protected abstract getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string;
private async _openUrl(url: string): Promise<{}> {
return url && commands.executeCommand(BuiltInCommands.Open, Uri.parse(url));
private async _openUrl(url: string): Promise<{} | undefined> {
if (url === undefined) return undefined;
return commands.executeCommand(BuiltInCommands.Open, Uri.parse(url));
}
open(type: 'branch', branch: string): Promise<{}>;