Browse Source

Changes naming for consistency

main
Eric Amodio 7 years ago
parent
commit
14ed9a4303
21 changed files with 86 additions and 86 deletions
  1. +2
    -2
      src/annotations/annotationProvider.ts
  2. +4
    -4
      src/annotations/annotations.ts
  3. +2
    -2
      src/commands/closeUnchangedFiles.ts
  4. +4
    -4
      src/commands/common.ts
  5. +1
    -1
      src/commands/diffDirectory.ts
  6. +1
    -1
      src/commands/openChangedFiles.ts
  7. +4
    -4
      src/git/models/logCommit.ts
  8. +2
    -2
      src/git/parsers/blameParser.ts
  9. +6
    -6
      src/git/parsers/logParser.ts
  10. +5
    -5
      src/git/parsers/stashParser.ts
  11. +5
    -5
      src/git/parsers/statusParser.ts
  12. +6
    -6
      src/git/remotes/provider.ts
  13. +3
    -3
      src/gitCodeLensProvider.ts
  14. +9
    -9
      src/gitService.ts
  15. +10
    -10
      src/messages.ts
  16. +1
    -1
      src/quickPicks/branches.ts
  17. +2
    -2
      src/quickPicks/remotes.ts
  18. +13
    -13
      src/quickPicks/repoStatus.ts
  19. +3
    -3
      src/system/array.ts
  20. +1
    -1
      src/system/iterable.ts
  21. +2
    -2
      src/telemetry.ts

+ 2
- 2
src/annotations/annotationProvider.ts View File

@ -34,7 +34,7 @@ export abstract class AnnotationProviderBase extends Disposable {
this._config = workspace.getConfiguration().get<IConfig>(ExtensionKey)!;
const subscriptions: Disposable[] = [
window.onDidChangeTextEditorSelection(this._onTextEditorSelectionChanged, this)
window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
}
@ -45,7 +45,7 @@ export abstract class AnnotationProviderBase extends Disposable {
this._disposable && this._disposable.dispose();
}
private async _onTextEditorSelectionChanged(e: TextEditorSelectionChangeEvent) {
private async onTextEditorSelectionChanged(e: TextEditorSelectionChangeEvent) {
if (!TextDocumentComparer.equals(this.document, e.textEditor && e.textEditor.document)) return;
return this.selection(e.selections[0].active.line);

+ 4
- 4
src/annotations/annotations.ts View File

@ -29,11 +29,11 @@ const escapeMarkdownRegEx = /[`\>\#\*\_\-\+\.]/g;
export class Annotations {
static applyHeatmap(decoration: DecorationOptions, date: Date, now: number) {
const color = this._getHeatmapColor(now, date);
const color = this.getHeatmapColor(now, date);
(decoration.renderOptions!.before! as any).borderColor = color;
}
private static _getHeatmapColor(now: number, date: Date) {
private static getHeatmapColor(now: number, date: Date) {
const days = Dates.dateDaysFromNow(date, now);
if (days <= 2) return '#ffeca7';
@ -104,7 +104,7 @@ export class Annotations {
static getHoverDiffMessage(commit: GitCommit, chunkLine: GitDiffChunkLine | undefined): MarkdownString | undefined {
if (chunkLine === undefined || commit.previousSha === undefined) return undefined;
const codeDiff = this._getCodeDiff(chunkLine);
const codeDiff = this.getCodeDiff(chunkLine);
const markdown = new MarkdownString(commit.isUncommitted
? `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs(commit)} "Open Changes") &nbsp; ${GlyphChars.Dash} &nbsp; _uncommitted_\n${codeDiff}`
: `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs(commit)} "Open Changes") &nbsp; ${GlyphChars.Dash} &nbsp; [\`${commit.previousShortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.previousSha!)} "Show Commit Details") ${GlyphChars.ArrowLeftRight} [\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.sha)} "Show Commit Details")\n${codeDiff}`);
@ -112,7 +112,7 @@ export class Annotations {
return markdown;
}
private static _getCodeDiff(chunkLine: GitDiffChunkLine): string {
private static getCodeDiff(chunkLine: GitDiffChunkLine): string {
const previous = chunkLine.previous === undefined ? undefined : chunkLine.previous[0];
return `\`\`\`
- ${previous === undefined || previous.line === undefined ? '' : previous.line.trim()}

+ 2
- 2
src/commands/closeUnchangedFiles.ts View File

@ -31,7 +31,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
const status = await this.git.getStatusForRepo(repoPath);
if (status === undefined) return window.showWarningMessage(`Unable to close unchanged files`);
args.uris = status.files.map(_ => _.Uri);
args.uris = status.files.map(f => f.Uri);
}
if (args.uris.length === 0) return commands.executeCommand(BuiltInCommands.CloseAllEditors);
@ -48,7 +48,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
}
if (editor.document !== undefined &&
(editor.document.isDirty || args.uris.some(_ => UriComparer.equals(_, editor!.document && editor!.document.uri)))) {
(editor.document.isDirty || args.uris.some(uri => UriComparer.equals(uri, editor!.document && editor!.document.uri)))) {
const lastPrevious = previous;
previous = editor;
editor = await editorTracker.awaitNext(500);

+ 4
- 4
src/commands/common.ts View File

@ -163,11 +163,11 @@ export abstract class Command extends Disposable {
protected _execute(command: string, ...args: any[]): any {
Telemetry.trackEvent(command);
const [context, rest] = Command._parseContext(command, this.contextParsingOptions, ...args);
const [context, rest] = Command.parseContext(command, this.contextParsingOptions, ...args);
return this.preExecute(context, ...rest);
}
private static _parseContext(command: string, options: CommandContextParsingOptions, ...args: any[]): [CommandContext, any[]] {
private static parseContext(command: string, options: CommandContextParsingOptions, ...args: any[]): [CommandContext, any[]] {
let editor: TextEditor | undefined = undefined;
let firstArg = args[0];
@ -271,7 +271,7 @@ export abstract class EditorCommand extends Disposable {
const subscriptions = [];
for (const cmd of command) {
subscriptions.push(commands.registerTextEditorCommand(cmd, (editor: TextEditor, edit: TextEditorEdit, ...args: any[]) => this._execute(cmd, editor, edit, ...args), this));
subscriptions.push(commands.registerTextEditorCommand(cmd, (editor: TextEditor, edit: TextEditorEdit, ...args: any[]) => this.executeCore(cmd, editor, edit, ...args), this));
}
this._disposable = Disposable.from(...subscriptions);
}
@ -280,7 +280,7 @@ export abstract class EditorCommand extends Disposable {
this._disposable && this._disposable.dispose();
}
private _execute(command: string, editor: TextEditor, edit: TextEditorEdit, ...args: any[]): any {
private executeCore(command: string, editor: TextEditor, edit: TextEditorEdit, ...args: any[]): any {
Telemetry.trackEvent(command);
return this.execute(editor, edit, ...args);
}

+ 1
- 1
src/commands/diffDirectory.ts View File

@ -48,7 +48,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
args = { ...args };
const branches = await this.git.getBranches(repoPath);
const current = Iterables.find(branches, _ => _.current);
const current = Iterables.find(branches, b => b.current);
if (current == null) return window.showWarningMessage(`Unable to open directory compare`);
const pick = await BranchesQuickPick.show(branches, `Compare ${current.name} to ${GlyphChars.Ellipsis}`);

+ 1
- 1
src/commands/openChangedFiles.ts View File

@ -28,7 +28,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
const status = await this.git.getStatusForRepo(repoPath);
if (status === undefined) return window.showWarningMessage(`Unable to open changed files`);
args.uris = status.files.filter(_ => _.status !== 'D').map(_ => _.Uri);
args.uris = status.files.filter(f => f.status !== 'D').map(f => f.Uri);
}
for (const uri of args.uris) {

+ 4
- 4
src/git/models/logCommit.ts View File

@ -33,7 +33,7 @@ export class GitLogCommit extends GitCommit {
this.fileNames = this.fileName;
if (fileStatuses) {
this.fileStatuses = fileStatuses.filter(_ => !!_.fileName);
this.fileStatuses = fileStatuses.filter(f => !!f.fileName);
const fileStatus = this.fileStatuses[0];
this.fileName = fileStatus.fileName;
@ -63,9 +63,9 @@ export class GitLogCommit extends GitCommit {
}
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;
const added = this.fileStatuses.filter(f => f.status === 'A' || f.status === '?').length;
const deleted = this.fileStatuses.filter(f => f.status === 'D').length;
const changed = this.fileStatuses.filter(f => f.status !== 'A' && f.status !== '?' && f.status !== 'D').length;
return `+${added} ~${changed} -${deleted}`;
}

+ 2
- 2
src/git/parsers/blameParser.ts View File

@ -90,7 +90,7 @@ export class GitBlameParser {
}
first = false;
GitBlameParser._parseEntry(entry, repoPath, relativeFileName, commits, authors, lines);
GitBlameParser.parseEntry(entry, repoPath, relativeFileName, commits, authors, lines);
entry = undefined;
break;
@ -119,7 +119,7 @@ export class GitBlameParser {
} as GitBlame;
}
private static _parseEntry(entry: BlameEntry, repoPath: string | undefined, fileName: string | undefined, commits: Map<string, GitBlameCommit>, authors: Map<string, GitAuthor>, lines: GitCommitLine[]) {
private static parseEntry(entry: BlameEntry, repoPath: string | undefined, fileName: string | undefined, commits: Map<string, GitBlameCommit>, authors: Map<string, GitAuthor>, lines: GitCommitLine[]) {
let commit = commits.get(entry.sha);
if (commit === undefined) {
if (entry.author !== undefined) {

+ 6
- 6
src/git/parsers/logParser.ts View File

@ -164,13 +164,13 @@ export class GitLogParser {
fileName: line.substring(1),
originalFileName: undefined
} as IGitStatusFile;
this._parseFileName(status);
this.parseFileName(status);
entry.fileStatuses.push(status);
}
if (entry.fileStatuses) {
entry.fileName = entry.fileStatuses.filter(_ => !!_.fileName).map(_ => _.fileName).join(', ');
entry.fileName = entry.fileStatuses.filter(f => !!f.fileName).map(f => f.fileName).join(', ');
}
}
else {
@ -182,7 +182,7 @@ export class GitLogParser {
entry.status = line[0] as GitStatusFileStatus;
entry.fileName = line.substring(1);
this._parseFileName(entry);
this.parseFileName(entry);
}
if (first && repoPath === undefined && type === GitCommitType.File && fileName !== undefined) {
@ -195,7 +195,7 @@ export class GitLogParser {
}
first = false;
recentCommit = GitLogParser._parseEntry(entry, type, repoPath, relativeFileName, commits, authors, recentCommit);
recentCommit = GitLogParser.parseEntry(entry, type, repoPath, relativeFileName, commits, authors, recentCommit);
entry = undefined;
break;
@ -216,7 +216,7 @@ export class GitLogParser {
} as GitLog;
}
private static _parseEntry(entry: LogEntry, type: GitCommitType, repoPath: string | undefined, relativeFileName: string, commits: Map<string, GitLogCommit>, authors: Map<string, GitAuthor>, recentCommit: GitLogCommit | undefined): GitLogCommit | undefined {
private static parseEntry(entry: LogEntry, type: GitCommitType, repoPath: string | undefined, relativeFileName: string, commits: Map<string, GitLogCommit>, authors: Map<string, GitAuthor>, recentCommit: GitLogCommit | undefined): GitLogCommit | undefined {
let commit = commits.get(entry.sha);
if (commit === undefined) {
if (entry.author !== undefined) {
@ -258,7 +258,7 @@ export class GitLogParser {
return commit;
}
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {
private static parseFileName(entry: { fileName?: string, originalFileName?: string }) {
if (entry.fileName === undefined) return;
const index = entry.fileName.indexOf('\t') + 1;

+ 5
- 5
src/git/parsers/stashParser.ts View File

@ -14,7 +14,7 @@ interface StashEntry {
export class GitStashParser {
static parse(data: string, repoPath: string): GitStash | undefined {
const entries = this._parseEntries(data);
const entries = this.parseEntries(data);
if (entries === undefined) return undefined;
const commits: Map<string, GitStashCommit> = new Map();
@ -35,7 +35,7 @@ export class GitStashParser {
} as GitStash;
}
private static _parseEntries(data: string): StashEntry[] | undefined {
private static parseEntries(data: string): StashEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
@ -114,13 +114,13 @@ export class GitStashParser {
fileName: line.substring(1),
originalFileName: undefined
} as IGitStatusFile;
this._parseFileName(status);
this.parseFileName(status);
entry.fileStatuses.push(status);
}
if (entry.fileStatuses) {
entry.fileNames = entry.fileStatuses.filter(_ => !!_.fileName).map(_ => _.fileName).join(', ');
entry.fileNames = entry.fileStatuses.filter(f => !!f.fileName).map(f => f.fileName).join(', ');
}
entries.push(entry);
@ -135,7 +135,7 @@ export class GitStashParser {
return entries;
}
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {
private static parseFileName(entry: { fileName?: string, originalFileName?: string }) {
if (entry.fileName === undefined) return;
const index = entry.fileName.indexOf('\t') + 1;

+ 5
- 5
src/git/parsers/statusParser.ts View File

@ -9,7 +9,7 @@ export class GitStatusParser {
static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined {
if (!data) return undefined;
const lines = data.split('\n').filter(_ => !!_);
const lines = data.split('\n').filter(l => !!l);
if (lines.length === 0) return undefined;
const status = {
@ -24,16 +24,16 @@ export class GitStatusParser {
};
if (porcelainVersion >= 2) {
this._parseV2(lines, repoPath, status);
this.parseV2(lines, repoPath, status);
}
else {
this._parseV1(lines, repoPath, status);
this.parseV1(lines, repoPath, status);
}
return status;
}
private static _parseV1(lines: string[], repoPath: string, status: GitStatus) {
private static parseV1(lines: string[], repoPath: string, status: GitStatus) {
let position = -1;
while (++position < lines.length) {
const line = lines[position];
@ -65,7 +65,7 @@ export class GitStatusParser {
}
}
private static _parseV2(lines: string[], repoPath: string, status: GitStatus) {
private static parseV2(lines: string[], repoPath: string, status: GitStatus) {
let position = -1;
while (++position < lines.length) {
const line = lines[position];

+ 6
- 6
src/git/remotes/provider.ts View File

@ -69,7 +69,7 @@ export abstract class RemoteProvider {
protected abstract getUrlForCommit(sha: string): string;
protected abstract getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string;
private async _openUrl(url: string): Promise<{} | undefined> {
private async openUrl(url: string): Promise<{} | undefined> {
if (url === undefined) return undefined;
return commands.executeCommand(BuiltInCommands.Open, Uri.parse(url));
@ -87,22 +87,22 @@ export abstract class RemoteProvider {
}
openRepo() {
return this._openUrl(this.getUrlForRepository());
return this.openUrl(this.getUrlForRepository());
}
openBranches() {
return this._openUrl(this.getUrlForBranches());
return this.openUrl(this.getUrlForBranches());
}
openBranch(branch: string) {
return this._openUrl(this.getUrlForBranch(branch));
return this.openUrl(this.getUrlForBranch(branch));
}
openCommit(sha: string) {
return this._openUrl(this.getUrlForCommit(sha));
return this.openUrl(this.getUrlForCommit(sha));
}
openFile(fileName: string, branch?: string, sha?: string, range?: Range) {
return this._openUrl(this.getUrlForFile(fileName, branch, sha, range));
return this.openUrl(this.getUrlForFile(fileName, branch, sha, range));
}
}

+ 3
- 3
src/gitCodeLensProvider.ts View File

@ -69,7 +69,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
const dirty = document.isDirty;
let languageLocations = this._config.codeLens.perLanguageLocations.find(_ => _.language !== undefined && _.language.toLowerCase() === document.languageId);
let languageLocations = this._config.codeLens.perLanguageLocations.find(ll => ll.language !== undefined && ll.language.toLowerCase() === document.languageId);
if (languageLocations == null) {
languageLocations = {
language: undefined,
@ -79,7 +79,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
}
languageLocations.customSymbols = languageLocations.customSymbols != null
? languageLocations.customSymbols = languageLocations.customSymbols.map(_ => _.toLowerCase())
? languageLocations.customSymbols = languageLocations.customSymbols.map(s => s.toLowerCase())
: [];
const lenses: CodeLens[] = [];
@ -304,7 +304,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
const count = blame.authors.size;
let title = `${count} ${count > 1 ? 'authors' : 'author'} (${Iterables.first(blame.authors.values()).name}${count > 1 ? ' and others' : ''})`;
if (this._config.codeLens.debug) {
title += ` [${SymbolKind[lens.symbolKind]}(${lens.range.start.character}-${lens.range.end.character}), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1}), Authors (${Iterables.join(Iterables.map(blame.authors.values(), _ => _.name), ', ')})]`;
title += ` [${SymbolKind[lens.symbolKind]}(${lens.range.start.character}-${lens.range.end.character}), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1}), Authors (${Iterables.join(Iterables.map(blame.authors.values(), a => a.name), ', ')})]`;
}
switch (this._config.codeLens.authors.command) {

+ 9
- 9
src/gitService.ts View File

@ -30,7 +30,7 @@ class GitCacheEntry {
constructor(public readonly key: string) { }
get hasErrors(): boolean {
return Iterables.every(this.cache.values(), _ => _.errorMessage !== undefined);
return Iterables.every(this.cache.values(), entry => entry.errorMessage !== undefined);
}
get<T extends CachedBlame | CachedDiff | CachedLog>(key: string): T | undefined {
@ -380,7 +380,7 @@ export class GitService extends Disposable {
if (log === undefined) return undefined;
const c = Iterables.first(log.commits.values());
const status = c.fileStatuses.find(_ => _.originalFileName === fileName);
const status = c.fileStatuses.find(f => f.originalFileName === fileName);
if (status === undefined) return undefined;
return status.fileName;
@ -717,7 +717,7 @@ export class GitService extends Disposable {
const diff = await this.getDiffForFile(uri, sha1, sha2);
if (diff === undefined) return undefined;
const chunk = diff.chunks.find(_ => _.currentPosition.start <= line && _.currentPosition.end >= line);
const chunk = diff.chunks.find(c => c.currentPosition.start <= line && c.currentPosition.end >= line);
if (chunk === undefined) return undefined;
return chunk.lines[line - chunk.currentPosition.start + 1];
@ -1137,10 +1137,10 @@ export class GitService extends Disposable {
static fromGitContentUri(uri: Uri): IGitUriData {
if (uri.scheme !== DocumentSchemes.GitLensGit) throw new Error(`fromGitUri(uri=${uri}) invalid scheme`);
return GitService._fromGitContentUri<IGitUriData>(uri);
return GitService.fromGitContentUriCore<IGitUriData>(uri);
}
private static _fromGitContentUri<T extends IGitUriData>(uri: Uri): T {
private static fromGitContentUriCore<T extends IGitUriData>(uri: Uri): T {
return JSON.parse(uri.query) as T;
}
@ -1168,7 +1168,7 @@ export class GitService extends Disposable {
let data: IGitUriData;
let shortSha: string | undefined;
if (typeof shaOrcommitOrUri === 'string') {
data = GitService._toGitUriData({
data = GitService.toGitUriData({
sha: shaOrcommitOrUri,
fileName: fileName!,
repoPath: repoPath!,
@ -1177,12 +1177,12 @@ export class GitService extends Disposable {
shortSha = GitService.shortenSha(shaOrcommitOrUri);
}
else if (shaOrcommitOrUri instanceof GitCommit) {
data = GitService._toGitUriData(shaOrcommitOrUri, shaOrcommitOrUri.originalFileName);
data = GitService.toGitUriData(shaOrcommitOrUri, shaOrcommitOrUri.originalFileName);
fileName = shaOrcommitOrUri.fileName;
shortSha = shaOrcommitOrUri.shortSha;
}
else {
data = GitService._toGitUriData({
data = GitService.toGitUriData({
sha: shaOrcommitOrUri.sha!,
fileName: shaOrcommitOrUri.fsPath!,
repoPath: shaOrcommitOrUri.repoPath!
@ -1195,7 +1195,7 @@ export class GitService extends Disposable {
return Uri.parse(`${DocumentSchemes.GitLensGit}:${parsed.dir}${parsed.name}:${shortSha}${parsed.ext}?${JSON.stringify(data)}`);
}
private static _toGitUriData<T extends IGitUriData>(commit: IGitUriData, originalFileName?: string): T {
private static toGitUriData<T extends IGitUriData>(commit: IGitUriData, originalFileName?: string): T {
const fileName = Git.normalizePath(path.resolve(commit.repoPath, commit.fileName));
const data = { repoPath: commit.repoPath, fileName: fileName, sha: commit.sha } as T;
if (originalFileName) {

+ 10
- 10
src/messages.ts View File

@ -24,33 +24,33 @@ export class Messages {
}
static showCommitHasNoPreviousCommitWarningMessage(commit?: GitCommit): Promise<string | undefined> {
if (commit === undefined) return Messages._showMessage('info', `Commit has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
return Messages._showMessage('info', `Commit ${commit.shortSha} (${commit.author}, ${commit.fromNow()}) has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
if (commit === undefined) return Messages.showMessage('info', `Commit has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
return Messages.showMessage('info', `Commit ${commit.shortSha} (${commit.author}, ${commit.fromNow()}) has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
}
static showCommitNotFoundWarningMessage(message: string): Promise<string | undefined> {
return Messages._showMessage('warn', `${message}. The commit could not be found`, SuppressedKeys.CommitNotFoundWarning);
return Messages.showMessage('warn', `${message}. The commit could not be found`, SuppressedKeys.CommitNotFoundWarning);
}
static showFileNotUnderSourceControlWarningMessage(message: string): Promise<string | undefined> {
return Messages._showMessage('warn', `${message}. The file is probably not under source control`, SuppressedKeys.FileNotUnderSourceControlWarning);
return Messages.showMessage('warn', `${message}. The file is probably not under source control`, SuppressedKeys.FileNotUnderSourceControlWarning);
}
static showLineUncommittedWarningMessage(message: string): Promise<string | undefined> {
return Messages._showMessage('warn', `${message}. The line has uncommitted changes`, SuppressedKeys.LineUncommittedWarning);
return Messages.showMessage('warn', `${message}. The line has uncommitted changes`, SuppressedKeys.LineUncommittedWarning);
}
static showNoRepositoryWarningMessage(message: string): Promise<string | undefined> {
return Messages._showMessage('warn', `${message}. No repository could be found`, SuppressedKeys.NoRepositoryWarning);
return Messages.showMessage('warn', `${message}. No repository could be found`, SuppressedKeys.NoRepositoryWarning);
}
static showUnsupportedGitVersionErrorMessage(version: string): Promise<string | undefined> {
return Messages._showMessage('error', `GitLens requires a newer version of Git (>= 2.2.0) than is currently installed (${version}). Please install a more recent version of Git.`, SuppressedKeys.GitVersionWarning);
return Messages.showMessage('error', `GitLens requires a newer version of Git (>= 2.2.0) than is currently installed (${version}). Please install a more recent version of Git.`, SuppressedKeys.GitVersionWarning);
}
static async showUpdateMessage(version: string): Promise<string | undefined> {
const viewReleaseNotes = 'View Release Notes';
const result = await Messages._showMessage('info', `GitLens has been updated to v${version}`, SuppressedKeys.UpdateNotice, undefined, viewReleaseNotes);
const result = await Messages.showMessage('info', `GitLens has been updated to v${version}`, SuppressedKeys.UpdateNotice, undefined, viewReleaseNotes);
if (result === viewReleaseNotes) {
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens/changelog'));
}
@ -59,14 +59,14 @@ export class Messages {
static async showWelcomeMessage(): Promise<string | undefined> {
const viewDocs = 'View Docs';
const result = await Messages._showMessage('info', `Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs.`, SuppressedKeys.WelcomeNotice, null, viewDocs);
const result = await Messages.showMessage('info', `Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs.`, SuppressedKeys.WelcomeNotice, null, viewDocs);
if (result === viewDocs) {
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens'));
}
return result;
}
private static async _showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedKeys, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> {
private static async showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedKeys, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> {
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`);
if (Messages.context.globalState.get(suppressionKey, false)) {

+ 1
- 1
src/quickPicks/branches.ts View File

@ -20,7 +20,7 @@ export class BranchesQuickPick {
static async show(branches: GitBranch[], placeHolder: string, goBackCommand?: CommandQuickPickItem): Promise<BranchQuickPickItem | CommandQuickPickItem | undefined> {
const items = branches.map(_ => new BranchQuickPickItem(_)) as (BranchQuickPickItem | CommandQuickPickItem)[];
const items = branches.map(b => new BranchQuickPickItem(b)) as (BranchQuickPickItem | CommandQuickPickItem)[];
if (goBackCommand) {
items.splice(0, 0, goBackCommand);

+ 2
- 2
src/quickPicks/remotes.ts View File

@ -90,7 +90,7 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
return;
}
const provider = remotes.every(_ => _.provider !== undefined && _.provider.name === remote.provider!.name)
const provider = remotes.every(r => r.provider !== undefined && r.provider.name === remote.provider!.name)
? remote.provider!.name
: 'Remote';
@ -111,7 +111,7 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
export class RemotesQuickPick {
static async show(remotes: GitRemote[], placeHolder: string, resource: RemoteResource, goBackCommand?: CommandQuickPickItem): Promise<OpenRemoteCommandQuickPickItem | CommandQuickPickItem | undefined> {
const items = remotes.map(_ => new OpenRemoteCommandQuickPickItem(_, resource)) as (OpenRemoteCommandQuickPickItem | CommandQuickPickItem)[];
const items = remotes.map(r => new OpenRemoteCommandQuickPickItem(r, resource)) as (OpenRemoteCommandQuickPickItem | CommandQuickPickItem)[];
if (goBackCommand) {
items.splice(0, 0, goBackCommand);

+ 13
- 13
src/quickPicks/repoStatus.ts View File

@ -35,7 +35,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem {
constructor(statuses: GitStatusFile[], item?: QuickPickItem) {
const uris = statuses.map(_ => _.Uri);
const uris = statuses.map(f => f.Uri);
super(item || {
label: `$(file-symlink-file) Open Changed Files`,
@ -57,18 +57,18 @@ export class RepoStatusQuickPick {
const files = status.files;
files.sort((a, b) => (a.staged ? -1 : 1) - (b.staged ? -1 : 1) || a.fileName.localeCompare(b.fileName));
const added = files.filter(_ => _.status === 'A' || _.status === '?');
const deleted = files.filter(_ => _.status === 'D');
const changed = files.filter(_ => _.status !== 'A' && _.status !== '?' && _.status !== 'D');
const added = files.filter(f => f.status === 'A' || f.status === '?');
const deleted = files.filter(f => f.status === 'D');
const changed = files.filter(f => f.status !== 'A' && f.status !== '?' && f.status !== 'D');
const hasStaged = files.some(_ => _.staged);
const hasStaged = files.some(f => f.staged);
let stagedStatus = '';
let unstagedStatus = '';
if (hasStaged) {
const stagedAdded = added.filter(_ => _.staged).length;
const stagedChanged = changed.filter(_ => _.staged).length;
const stagedDeleted = deleted.filter(_ => _.staged).length;
const stagedAdded = added.filter(f => f.staged).length;
const stagedChanged = changed.filter(f => f.staged).length;
const stagedDeleted = deleted.filter(f => f.staged).length;
stagedStatus = `+${stagedAdded} ~${stagedChanged} -${stagedDeleted}`;
unstagedStatus = `+${added.length - stagedAdded} ~${changed.length - stagedChanged} -${deleted.length - stagedDeleted}`;
@ -91,7 +91,7 @@ export class RepoStatusQuickPick {
if (hasStaged) {
let index = 0;
const unstagedIndex = files.findIndex(_ => !_.staged);
const unstagedIndex = files.findIndex(f => !f.staged);
if (unstagedIndex > -1) {
items.splice(unstagedIndex, 0, new CommandQuickPickItem({
label: `Unstaged Files`,
@ -103,12 +103,12 @@ export class RepoStatusQuickPick {
} as ShowQuickRepoStatusCommandArgs
]));
items.splice(unstagedIndex, 0, new OpenStatusFilesCommandQuickPickItem(files.filter(_ => _.status !== 'D' && _.staged), {
items.splice(unstagedIndex, 0, new OpenStatusFilesCommandQuickPickItem(files.filter(f => f.status !== 'D' && f.staged), {
label: `${GlyphChars.Space.repeat(4)} $(file-symlink-file) Open Staged Files`,
description: ''
}));
items.push(new OpenStatusFilesCommandQuickPickItem(files.filter(_ => _.status !== 'D' && !_.staged), {
items.push(new OpenStatusFilesCommandQuickPickItem(files.filter(f => f.status !== 'D' && !f.staged), {
label: `${GlyphChars.Space.repeat(4)} $(file-symlink-file) Open Unstaged Files`,
description: ''
}));
@ -124,7 +124,7 @@ export class RepoStatusQuickPick {
} as ShowQuickRepoStatusCommandArgs
]));
}
else if (files.some(_ => !_.staged)) {
else if (files.some(f => !f.staged)) {
items.splice(0, 0, new CommandQuickPickItem({
label: `Unstaged Files`,
description: unstagedStatus
@ -137,7 +137,7 @@ export class RepoStatusQuickPick {
}
if (files.length) {
items.push(new OpenStatusFilesCommandQuickPickItem(files.filter(_ => _.status !== 'D')));
items.push(new OpenStatusFilesCommandQuickPickItem(files.filter(f => f.status !== 'D')));
items.push(new CommandQuickPickItem({
label: '$(x) Close Unchanged Files',
description: ''

+ 3
- 3
src/system/array.ts View File

@ -112,12 +112,12 @@ export namespace Arrays {
export function uniqueBy<T>(array: T[], accessor: (item: T) => any, predicate?: (item: T) => boolean): T[] {
const uniqueValues = Object.create(null);
return array.filter(_ => {
const value = accessor(_);
return array.filter(item => {
const value = accessor(item);
if (uniqueValues[value]) return false;
uniqueValues[value] = accessor;
return predicate ? predicate(_) : true;
return predicate ? predicate(item) : true;
});
}
}

+ 1
- 1
src/system/iterable.ts View File

@ -47,7 +47,7 @@ export namespace Iterables {
}
export function has<T>(source: Iterable<T> | IterableIterator<T>, item: T): boolean {
return some(source, _ => _ === item);
return some(source, i => i === item);
}
export function isIterable(source: Iterable<any>): boolean {

+ 2
- 2
src/telemetry.ts View File

@ -64,7 +64,7 @@ export class TelemetryReporter {
}
this.setContext();
this._stripPII(this._client);
this.stripPII(this._client);
}
setContext(context?: { [key: string]: string }) {
@ -96,7 +96,7 @@ export class TelemetryReporter {
this._client.trackException(ex);
}
private _stripPII(client: Client) {
private stripPII(client: Client) {
if (client && client.context && client.context.keys && client.context.tags) {
const machineNameKey = client.context.keys.deviceMachineName;
client.context.tags[machineNameKey] = '';

Loading…
Cancel
Save