Removes I from interface naming of "things"

This commit is contained in:
Eric Amodio
2017-06-09 17:58:42 -04:00
parent eb3b9ad6c9
commit eeff31cf27
29 changed files with 180 additions and 198 deletions

View File

@@ -2,12 +2,12 @@
import { Iterables } from '../system';
import { ExtensionContext, Range, TextEditor, TextEditorDecorationType } from 'vscode';
import { AnnotationProviderBase } from './annotationProvider';
import { GitService, GitUri, IGitBlame } from '../gitService';
import { GitBlame, GitService, GitUri } from '../gitService';
import { WhitespaceController } from './whitespaceController';
export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase {
protected _blame: Promise<IGitBlame>;
protected _blame: Promise<GitBlame>;
constructor(context: ExtensionContext, editor: TextEditor, decoration: TextEditorDecorationType, highlightDecoration: TextEditorDecorationType | undefined, whitespaceController: WhitespaceController | undefined, protected git: GitService, protected uri: GitUri) {
super(context, editor, decoration, highlightDecoration, whitespaceController);
@@ -15,7 +15,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
this._blame = this.git.getBlameForFile(this.uri);
}
async selection(shaOrLine?: string | number, blame?: IGitBlame) {
async selection(shaOrLine?: string | number, blame?: GitBlame) {
if (!this.highlightDecoration) return;
if (blame === undefined) {
@@ -57,14 +57,14 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
return blame !== undefined && blame.lines.length !== 0;
}
protected async getBlame(requiresWhitespaceHack: boolean): Promise<IGitBlame | undefined> {
protected async getBlame(requiresWhitespaceHack: boolean): Promise<GitBlame | undefined> {
let whitespacePromise: Promise<void> | undefined;
// HACK: Until https://github.com/Microsoft/vscode/issues/11485 is fixed -- override whitespace (turn off)
if (requiresWhitespaceHack) {
whitespacePromise = this.whitespaceController && this.whitespaceController.override();
}
let blame: IGitBlame;
let blame: GitBlame;
if (whitespacePromise) {
[blame] = await Promise.all([this._blame, whitespacePromise]);
}

View File

@@ -1,7 +1,7 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
import { GitService, GitUri, IGitLog } from '../gitService';
import { GitLog, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks';
@@ -9,7 +9,7 @@ import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
export interface ShowQuickBranchHistoryCommandArgs {
branch?: string;
log?: IGitLog;
log?: GitLog;
maxCount?: number;
goBackCommand?: CommandQuickPickItem;

View File

@@ -1,7 +1,7 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
@@ -11,7 +11,7 @@ import * as path from 'path';
export interface ShowQuickCommitDetailsCommandArgs {
sha?: string;
commit?: GitCommit | GitLogCommit;
repoLog?: IGitLog;
repoLog?: GitLog;
goBackCommand?: CommandQuickPickItem;
}

View File

@@ -1,7 +1,7 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
@@ -11,7 +11,7 @@ import * as path from 'path';
export interface ShowQuickCommitFileDetailsCommandArgs {
sha?: string;
commit?: GitCommit | GitLogCommit;
fileLog?: IGitLog;
fileLog?: GitLog;
goBackCommand?: CommandQuickPickItem;
}

View File

@@ -1,7 +1,7 @@
'use strict';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
import { GitService, GitUri, IGitLog } from '../gitService';
import { GitLog, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
@@ -9,7 +9,7 @@ import { Messages } from '../messages';
import * as path from 'path';
export interface ShowQuickFileHistoryCommandArgs {
log?: IGitLog;
log?: GitLog;
maxCount?: number;
range?: Range;

View File

@@ -7,7 +7,7 @@ import { Commands } from './commands';
import { TextEditorComparer } from './comparers';
import { FileAnnotationType, IConfig, LineAnnotationType, StatusBarCommand } from './configuration';
import { DocumentSchemes, ExtensionKey } from './constants';
import { BlameabilityChangeEvent, CommitFormatter, GitCommit, GitContextTracker, GitService, GitUri, IGitCommitLine } from './gitService';
import { BlameabilityChangeEvent, CommitFormatter, GitCommit, GitCommitLine, GitContextTracker, GitService, GitUri } from './gitService';
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
after: {
@@ -181,7 +181,7 @@ export class CurrentLineController extends Disposable {
line = line - this._uri.offset;
let commit: GitCommit | undefined = undefined;
let commitLine: IGitCommitLine | undefined = undefined;
let commitLine: GitCommitLine | undefined = undefined;
// Since blame information isn't valid when there are unsaved changes -- don't show any status
if (this._blameable && line >= 0) {
const blameLine = await this.git.getBlameForLine(this._uri, line);
@@ -215,7 +215,7 @@ export class CurrentLineController extends Disposable {
editor.setDecorations(annotationDecoration, []);
}
async show(commit: GitCommit, blameLine: IGitCommitLine, editor: TextEditor, line: number) {
async show(commit: GitCommit, blameLine: GitCommitLine, editor: TextEditor, line: number) {
// I have no idea why I need this protection -- but it happens
if (editor.document === undefined) return;
@@ -247,7 +247,7 @@ export class CurrentLineController extends Disposable {
await this._updateBlame(editor.selection.active.line, editor);
}
private async _updateAnnotations(commit: GitCommit, blameLine: IGitCommitLine, editor: TextEditor, line?: number) {
private async _updateAnnotations(commit: GitCommit, blameLine: GitCommitLine, editor: TextEditor, line?: number) {
const cfg = this._config.blame.line;
if (!cfg.enabled) return;

View File

@@ -1,7 +1,7 @@
'use strict';
import { Strings } from '../../system';
import { GitCommit } from '../models/commit';
import { IGitDiffLine } from '../models/diff';
import { GitDiffLine } from '../models/diff';
import * as moment from 'moment';
export interface ICommitFormatOptions {
@@ -142,7 +142,7 @@ export class CommitFormatter {
return `\`${commit.shortSha}\` &nbsp; __${commit.author}__, ${moment(commit.date).fromNow()} &nbsp; _(${moment(commit.date).format(dateFormat)})_${message}`;
}
static toHoverDiff(commit: GitCommit, previous: IGitDiffLine | undefined, current: IGitDiffLine | undefined): string | undefined {
static toHoverDiff(commit: GitCommit, previous: GitDiffLine | undefined, current: GitDiffLine | undefined): string | undefined {
if (previous === undefined && current === undefined) return undefined;
const codeDiff = this._getCodeDiff(previous, current);
@@ -151,7 +151,7 @@ export class CommitFormatter {
: `\`Changes\` &nbsp; \u2014 &nbsp; \`${commit.previousShortSha}\` \u2194 \`${commit.shortSha}\`\n${codeDiff}`;
}
private static _getCodeDiff(previous: IGitDiffLine | undefined, current: IGitDiffLine | undefined): string {
private static _getCodeDiff(previous: GitDiffLine | undefined, current: GitDiffLine | undefined): string {
return `\`\`\`
- ${previous === undefined ? '' : previous.line.trim()}
+ ${current === undefined ? '' : current.line.trim()}

View File

@@ -1,25 +1,25 @@
'use strict';
import { GitCommit, IGitAuthor, IGitCommitLine } from './commit';
import { GitAuthor, GitCommit, GitCommitLine } from './commit';
export interface IGitBlame {
export interface GitBlame {
repoPath: string;
authors: Map<string, IGitAuthor>;
authors: Map<string, GitAuthor>;
commits: Map<string, GitCommit>;
lines: IGitCommitLine[];
lines: GitCommitLine[];
}
export interface IGitBlameLine {
author: IGitAuthor;
export interface GitBlameLine {
author: GitAuthor;
commit: GitCommit;
line: IGitCommitLine;
line: GitCommitLine;
}
export interface IGitBlameLines extends IGitBlame {
allLines: IGitCommitLine[];
export interface GitBlameLines extends GitBlame {
allLines: GitCommitLine[];
}
export interface IGitBlameCommitLines {
author: IGitAuthor;
export interface GitBlameCommitLines {
author: GitAuthor;
commit: GitCommit;
lines: IGitCommitLine[];
lines: GitCommitLine[];
}

View File

@@ -3,30 +3,12 @@ import { Uri } from 'vscode';
import { Git } from '../git';
import * as path from 'path';
export interface IGitAuthor {
export interface GitAuthor {
name: string;
lineCount: number;
}
export interface IGitCommit {
type: GitCommitType;
repoPath: string;
sha: string;
fileName: string;
author?: string;
date: Date;
message: string;
lines: IGitCommitLine[];
originalFileName?: string;
previousSha?: string;
previousFileName?: string;
readonly isUncommitted: boolean;
previousUri: Uri;
uri: Uri;
}
export interface IGitCommitLine {
export interface GitCommitLine {
sha: string;
previousSha?: string;
line: number;
@@ -36,10 +18,10 @@ export interface IGitCommitLine {
export type GitCommitType = 'blame' | 'branch' | 'file' | 'stash';
export class GitCommit implements IGitCommit {
export class GitCommit {
type: GitCommitType;
lines: IGitCommitLine[];
lines: GitCommitLine[];
originalFileName?: string;
previousSha?: string;
previousFileName?: string;
@@ -54,7 +36,7 @@ export class GitCommit implements IGitCommit {
public author: string,
public date: Date,
public message: string,
lines?: IGitCommitLine[],
lines?: GitCommitLine[],
originalFileName?: string,
previousSha?: string,
previousFileName?: string

View File

@@ -1,24 +1,24 @@
'use strict';
export interface IGitDiffLine {
export interface GitDiffLine {
line: string;
state: 'added' | 'removed' | 'unchanged';
}
export interface IGitDiffChunk {
current: (IGitDiffLine | undefined)[];
export interface GitDiffChunk {
current: (GitDiffLine | undefined)[];
currentStart: number;
currentEnd: number;
previous: (IGitDiffLine | undefined)[];
previous: (GitDiffLine | undefined)[];
previousStart: number;
previousEnd: number;
chunk?: string;
}
export interface IGitDiff {
chunks: IGitDiffChunk[];
export interface GitDiff {
chunks: GitDiffChunk[];
diff?: string;
}

View File

@@ -1,11 +1,11 @@
'use strict';
import { Range } from 'vscode';
import { IGitAuthor } from './commit';
import { GitAuthor } from './commit';
import { GitLogCommit } from './logCommit';
export interface IGitLog {
export interface GitLog {
repoPath: string;
authors: Map<string, IGitAuthor>;
authors: Map<string, GitAuthor>;
commits: Map<string, GitLogCommit>;
sha: string | undefined;

View File

@@ -1,6 +1,6 @@
'use strict';
import { Uri } from 'vscode';
import { GitCommit, GitCommitType, IGitCommitLine } from './commit';
import { GitCommit, GitCommitLine, GitCommitType } from './commit';
import { GitStatusFileStatus, IGitStatusFile } from './status';
import * as path from 'path';
@@ -23,7 +23,7 @@ export class GitLogCommit extends GitCommit {
message: string,
status?: GitStatusFileStatus,
fileStatuses?: IGitStatusFile[],
lines?: IGitCommitLine[],
lines?: GitCommitLine[],
originalFileName?: string,
previousSha?: string,
previousFileName?: string

View File

@@ -1,7 +1,7 @@
'use strict';
import { GitStashCommit } from './stashCommit';
export interface IGitStash {
export interface GitStash {
repoPath: string;
commits: Map<string, GitStashCommit>;
}

View File

@@ -1,5 +1,5 @@
'use strict';
import { IGitCommitLine } from './commit';
import { GitCommitLine } from './commit';
import { GitLogCommit } from './logCommit';
import { GitStatusFileStatus, IGitStatusFile } from './status';
@@ -14,7 +14,7 @@ export class GitStashCommit extends GitLogCommit {
message: string,
status?: GitStatusFileStatus,
fileStatuses?: IGitStatusFile[],
lines?: IGitCommitLine[],
lines?: GitCommitLine[],
originalFileName?: string,
previousSha?: string,
previousFileName?: string

View File

@@ -2,7 +2,7 @@
import { Uri } from 'vscode';
import * as path from 'path';
export interface IGitStatus {
export interface GitStatus {
branch: string;
repoPath: string;

View File

@@ -1,9 +1,9 @@
'use strict';
import { Git, GitCommit, IGitAuthor, IGitBlame, IGitCommitLine } from './../git';
import { Git, GitAuthor, GitBlame, GitCommit, GitCommitLine } from './../git';
import * as moment from 'moment';
import * as path from 'path';
interface IBlameEntry {
interface BlameEntry {
sha: string;
line: number;
@@ -30,15 +30,15 @@ interface IBlameEntry {
export class GitBlameParser {
private static _parseEntries(data: string): IBlameEntry[] | undefined {
private static _parseEntries(data: string): BlameEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
if (!lines.length) return undefined;
const entries: IBlameEntry[] = [];
const entries: BlameEntry[] = [];
let entry: IBlameEntry | undefined = undefined;
let entry: BlameEntry | undefined = undefined;
let position = -1;
while (++position < lines.length) {
const lineParts = lines[position].split(' ');
@@ -50,7 +50,7 @@ export class GitBlameParser {
originalLine: parseInt(lineParts[1], 10) - 1,
line: parseInt(lineParts[2], 10) - 1,
lineCount: parseInt(lineParts[3], 10)
} as IBlameEntry;
} as BlameEntry;
continue;
}
@@ -114,13 +114,13 @@ export class GitBlameParser {
return entries;
}
static parse(data: string, repoPath: string | undefined, fileName: string): IGitBlame | undefined {
static parse(data: string, repoPath: string | undefined, fileName: string): GitBlame | undefined {
const entries = this._parseEntries(data);
if (!entries) return undefined;
const authors: Map<string, IGitAuthor> = new Map();
const authors: Map<string, GitAuthor> = new Map();
const commits: Map<string, GitCommit> = new Map();
const lines: IGitCommitLine[] = [];
const lines: GitCommitLine[] = [];
let relativeFileName = repoPath && fileName;
@@ -161,7 +161,7 @@ export class GitBlameParser {
}
for (let j = 0, len = entry.lineCount; j < len; j++) {
const line: IGitCommitLine = {
const line: GitCommitLine = {
sha: entry.sha,
line: entry.line + j,
originalLine: entry.originalLine + j
@@ -185,7 +185,7 @@ export class GitBlameParser {
author.lineCount += c.lines.length;
});
const sortedAuthors: Map<string, IGitAuthor> = new Map();
const sortedAuthors: Map<string, GitAuthor> = new Map();
// const values =
Array.from(authors.values())
.sort((a, b) => b.lineCount - a.lineCount)
@@ -202,6 +202,6 @@ export class GitBlameParser {
// commits: sortedCommits,
commits: commits,
lines: lines
} as IGitBlame;
} as GitBlame;
}
}

View File

@@ -1,14 +1,14 @@
'use strict';
import { IGitDiff, IGitDiffChunk, IGitDiffLine } from './../git';
import { GitDiff, GitDiffChunk, GitDiffLine } from './../git';
const unifiedDiffRegex = /^@@ -([\d]+),([\d]+) [+]([\d]+),([\d]+) @@([\s\S]*?)(?=^@@)/gm;
export class GitDiffParser {
static parse(data: string, debug: boolean = false): IGitDiff | undefined {
static parse(data: string, debug: boolean = false): GitDiff | undefined {
if (!data) return undefined;
const chunks: IGitDiffChunk[] = [];
const chunks: GitDiffChunk[] = [];
let match: RegExpExecArray | null = null;
do {
@@ -21,8 +21,8 @@ export class GitDiffParser {
const chunk = match[5];
const lines = chunk.split('\n').slice(1);
const current: (IGitDiffLine | undefined)[] = [];
const previous: (IGitDiffLine | undefined)[] = [];
const current: (GitDiffLine | undefined)[] = [];
const previous: (GitDiffLine | undefined)[] = [];
for (const l of lines) {
switch (l[0]) {
case '+':
@@ -64,7 +64,7 @@ export class GitDiffParser {
const diff = {
diff: debug ? data : undefined,
chunks: chunks
} as IGitDiff;
} as GitDiff;
return diff;
}
}

View File

@@ -1,11 +1,11 @@
'use strict';
import { Range } from 'vscode';
import { Git, GitCommitType, GitLogCommit, GitStatusFileStatus, IGitAuthor, IGitLog, IGitStatusFile } from './../git';
import { Git, GitAuthor, GitCommitType, GitLog, GitLogCommit, GitStatusFileStatus, IGitStatusFile } from './../git';
// import { Logger } from '../../logger';
import * as moment from 'moment';
import * as path from 'path';
interface ILogEntry {
interface LogEntry {
sha: string;
author: string;
@@ -29,15 +29,15 @@ const diffRegex = /diff --git a\/(.*) b\/(.*)/;
export class GitLogParser {
private static _parseEntries(data: string, type: GitCommitType, maxCount: number | undefined, reverse: boolean): ILogEntry[] | undefined {
private static _parseEntries(data: string, type: GitCommitType, maxCount: number | undefined, reverse: boolean): LogEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
if (!lines.length) return undefined;
const entries: ILogEntry[] = [];
const entries: LogEntry[] = [];
let entry: ILogEntry | undefined = undefined;
let entry: LogEntry | undefined = undefined;
let position = -1;
while (++position < lines.length) {
// Since log --reverse doesn't properly honor a max count -- enforce it here
@@ -53,7 +53,7 @@ export class GitLogParser {
entry = {
sha: lineParts[0]
} as ILogEntry;
} as LogEntry;
continue;
}
@@ -166,11 +166,11 @@ 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 | undefined): IGitLog | undefined {
static parse(data: string, type: GitCommitType, repoPath: string | undefined, fileName: string | undefined, sha: string | undefined, maxCount: number | undefined, reverse: boolean, range: Range | undefined): GitLog | undefined {
const entries = this._parseEntries(data, type, maxCount, reverse);
if (!entries) return undefined;
const authors: Map<string, IGitAuthor> = new Map();
const authors: Map<string, GitAuthor> = new Map();
const commits: Map<string, GitLogCommit> = new Map();
let relativeFileName: string;
@@ -245,7 +245,7 @@ export class GitLogParser {
author.lineCount += c.lines.length;
});
const sortedAuthors: Map<string, IGitAuthor> = new Map();
const sortedAuthors: Map<string, GitAuthor> = new Map();
// const values =
Array.from(authors.values())
.sort((a, b) => b.lineCount - a.lineCount)
@@ -265,7 +265,7 @@ export class GitLogParser {
maxCount: maxCount,
range: range,
truncated: !!(maxCount && entries.length >= maxCount)
} as IGitLog;
} as GitLog;
}
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {

View File

@@ -1,9 +1,9 @@
'use strict';
import { Git, GitStashCommit, GitStatusFileStatus, IGitStash, IGitStatusFile } from './../git';
import { Git, GitStash, GitStashCommit, GitStatusFileStatus, IGitStatusFile } from './../git';
// import { Logger } from '../../logger';
import * as moment from 'moment';
interface IStashEntry {
interface StashEntry {
sha: string;
date?: string;
fileNames: string;
@@ -14,15 +14,15 @@ interface IStashEntry {
export class GitStashParser {
private static _parseEntries(data: string): IStashEntry[] | undefined {
private static _parseEntries(data: string): StashEntry[] | undefined {
if (!data) return undefined;
const lines = data.split('\n');
if (!lines.length) return undefined;
const entries: IStashEntry[] = [];
const entries: StashEntry[] = [];
let entry: IStashEntry | undefined = undefined;
let entry: StashEntry | undefined = undefined;
let position = -1;
while (++position < lines.length) {
let lineParts = lines[position].split(' ');
@@ -35,7 +35,7 @@ export class GitStashParser {
entry = {
sha: lineParts[0]
} as IStashEntry;
} as StashEntry;
continue;
}
@@ -109,7 +109,7 @@ export class GitStashParser {
return entries;
}
static parse(data: string, repoPath: string): IGitStash | undefined {
static parse(data: string, repoPath: string): GitStash | undefined {
const entries = this._parseEntries(data);
if (entries === undefined) return undefined;
@@ -128,7 +128,7 @@ export class GitStashParser {
return {
repoPath: repoPath,
commits: commits
} as IGitStash;
} as GitStash;
}
private static _parseFileName(entry: { fileName?: string, originalFileName?: string }) {

View File

@@ -1,7 +1,7 @@
'use strict';
import { Git, GitStatusFile, GitStatusFileStatus, IGitStatus } from './../git';
import { Git, GitStatus, GitStatusFile, GitStatusFileStatus } from './../git';
interface IFileStatusEntry {
interface FileStatusEntry {
staged: boolean;
status: GitStatusFileStatus;
fileName: string;
@@ -13,7 +13,7 @@ const behindStatusV1Regex = /(?:behind ([0-9]+))/;
export class GitStatusParser {
static parse(data: string, repoPath: string, porcelainVersion: number): IGitStatus | undefined {
static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined {
if (!data) return undefined;
const lines = data.split('\n').filter(_ => !!_);
@@ -40,7 +40,7 @@ export class GitStatusParser {
return status;
}
private static _parseV1(lines: string[], repoPath: string, status: IGitStatus) {
private static _parseV1(lines: string[], repoPath: string, status: GitStatus) {
let position = -1;
while (++position < lines.length) {
const line = lines[position];
@@ -59,7 +59,7 @@ export class GitStatusParser {
}
}
else {
let entry: IFileStatusEntry;
let entry: FileStatusEntry;
const rawStatus = line.substring(0, 2);
const fileName = line.substring(3);
if (rawStatus[0] === 'R') {
@@ -74,7 +74,7 @@ export class GitStatusParser {
}
}
private static _parseV2(lines: string[], repoPath: string, status: IGitStatus) {
private static _parseV2(lines: string[], repoPath: string, status: GitStatus) {
let position = -1;
while (++position < lines.length) {
const line = lines[position];
@@ -99,7 +99,7 @@ export class GitStatusParser {
}
else {
const lineParts = line.split(' ');
let entry: IFileStatusEntry | undefined = undefined;
let entry: FileStatusEntry | undefined = undefined;
switch (lineParts[0][0]) {
case '1': // normal
entry = this._parseFileEntry(lineParts[1], lineParts.slice(8).join(' '));
@@ -123,7 +123,7 @@ export class GitStatusParser {
}
}
private static _parseFileEntry(rawStatus: string, fileName: string, originalFileName?: string): IFileStatusEntry {
private static _parseFileEntry(rawStatus: string, fileName: string, originalFileName?: string): FileStatusEntry {
const indexStatus = rawStatus[0] !== '.' ? rawStatus[0].trim() : undefined;
const workTreeStatus = rawStatus[1] !== '.' ? rawStatus[1].trim() : undefined;
@@ -132,6 +132,6 @@ export class GitStatusParser {
fileName: fileName,
originalFileName: originalFileName,
staged: !!indexStatus
} as IFileStatusEntry;
} as FileStatusEntry;
}
}

View File

@@ -4,28 +4,28 @@ import { CancellationToken, CodeLens, CodeLensProvider, Command, commands, Docum
import { Commands, DiffWithPreviousCommandArgs, ShowBlameHistoryCommandArgs, ShowFileHistoryCommandArgs, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from './commands';
import { BuiltInCommands, DocumentSchemes, ExtensionKey } from './constants';
import { CodeLensCommand, CodeLensLocations, ICodeLensLanguageLocation, IConfig } from './configuration';
import { GitCommit, GitService, GitUri, IGitBlame, IGitBlameLines } from './gitService';
import { GitBlame, GitBlameLines, GitCommit, GitService, GitUri } from './gitService';
import { Logger } from './logger';
import * as moment from 'moment';
export class GitRecentChangeCodeLens extends CodeLens {
constructor(private blame: () => IGitBlameLines | undefined, public uri: GitUri, public symbolKind: SymbolKind, public blameRange: Range, public isFullRange: boolean, range: Range) {
constructor(private blame: () => GitBlameLines | undefined, public uri: GitUri, public symbolKind: SymbolKind, public blameRange: Range, public isFullRange: boolean, range: Range) {
super(range);
}
getBlame(): IGitBlameLines | undefined {
getBlame(): GitBlameLines | undefined {
return this.blame();
}
}
export class GitAuthorsCodeLens extends CodeLens {
constructor(private blame: () => IGitBlameLines | undefined, public uri: GitUri, public symbolKind: SymbolKind, public blameRange: Range, public isFullRange: boolean, range: Range) {
constructor(private blame: () => GitBlameLines | undefined, public uri: GitUri, public symbolKind: SymbolKind, public blameRange: Range, public isFullRange: boolean, range: Range) {
super(range);
}
getBlame(): IGitBlameLines | undefined {
getBlame(): GitBlameLines | undefined {
return this.blame();
}
}
@@ -70,7 +70,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
const gitUri = await GitUri.fromUri(document.uri, this.git);
const blamePromise = this.git.getBlameForFile(gitUri);
let blame: IGitBlame | undefined;
let blame: GitBlame | undefined;
if (languageLocations.locations.length === 1 && languageLocations.locations.includes(CodeLensLocations.Document)) {
blame = await blamePromise;
if (blame === undefined || !blame.lines.length) return lenses;
@@ -81,7 +81,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
commands.executeCommand(BuiltInCommands.ExecuteDocumentSymbolProvider, document.uri) as Promise<any>
]);
blame = values[0] as IGitBlame;
blame = values[0] as GitBlame;
if (blame === undefined || !blame.lines.length) return lenses;
const symbols = values[1] as SymbolInformation[];
@@ -94,7 +94,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
// Check if we have a lens for the whole document -- if not add one
if (!lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0)) {
const blameRange = document.validateRange(new Range(0, 1000000, 1000000, 1000000));
let blameForRangeFn: (() => IGitBlameLines | undefined) | undefined = undefined;
let blameForRangeFn: (() => GitBlameLines | undefined) | undefined = undefined;
if (this._documentIsDirty || this._config.codeLens.recentChange.enabled) {
blameForRangeFn = Functions.once(() => this.git.getBlameForRangeSync(blame!, gitUri, blameRange));
lenses.push(new GitRecentChangeCodeLens(blameForRangeFn, gitUri, SymbolKind.File, blameRange, true, new Range(0, 0, 0, blameRange.start.character)));
@@ -176,7 +176,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return valid ? range || symbol.location.range : undefined;
}
private _provideCodeLens(gitUri: GitUri, document: TextDocument, symbol: SymbolInformation, languageLocation: ICodeLensLanguageLocation, blame: IGitBlame, lenses: CodeLens[]): void {
private _provideCodeLens(gitUri: GitUri, document: TextDocument, symbol: SymbolInformation, languageLocation: ICodeLensLanguageLocation, blame: GitBlame, lenses: CodeLens[]): void {
const blameRange = this._validateSymbolAndGetBlameRange(document, symbol, languageLocation);
if (!blameRange) return;
@@ -187,7 +187,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
// Anchor the code lens to the end of the line -- so they are somewhat consistenly placed
let startChar = line.range.end.character - 1;
let blameForRangeFn: (() => IGitBlameLines | undefined) | undefined = undefined;
let blameForRangeFn: (() => GitBlameLines | undefined) | undefined = undefined;
if (this._documentIsDirty || this._config.codeLens.recentChange.enabled) {
blameForRangeFn = Functions.once(() => this.git.getBlameForRangeSync(blame, gitUri, blameRange));
lenses.push(new GitRecentChangeCodeLens(blameForRangeFn, gitUri, symbol.kind, blameRange, false, line.range.with(new Position(line.range.start.line, startChar))));
@@ -256,7 +256,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
const recentCommit = Iterables.first(blame.commits.values());
title = `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`;
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}), Commit (${recentCommit.shortSha})]`;
title += ` [${SymbolKind[lens.symbolKind]}(${lens.range.start.character}-${lens.range.end.character}), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1}), Commit (${recentCommit.shortSha})]`;
}
switch (this._config.codeLens.recentChange.command) {
@@ -279,7 +279,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(), _ => _.name), ', ')})]`;
}
switch (this._config.codeLens.authors.command) {
@@ -295,7 +295,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
}
}
_applyBlameAnnotateCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines): T {
_applyBlameAnnotateCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines): T {
lens.command = {
title: title,
command: Commands.ToggleFileBlame,
@@ -304,7 +304,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowBlameHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyShowBlameHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
let line = lens.range.start.line;
if (commit) {
const blameLine = commit.lines.find(_ => _.line === line);
@@ -330,7 +330,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowFileHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyShowFileHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
let line = lens.range.start.line;
if (commit) {
const blameLine = commit.lines.find(_ => _.line === line);
@@ -355,7 +355,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyDiffWithPreviousCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyDiffWithPreviousCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
if (commit === undefined) {
const blameLine = blame.allLines[lens.range.start.line];
commit = blame.commits.get(blameLine.sha);
@@ -375,7 +375,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowQuickCommitDetailsCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyShowQuickCommitDetailsCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
lens.command = {
title: title,
command: commit !== undefined && commit.isUncommitted ? '' : CodeLensCommand.ShowQuickCommitDetails,
@@ -389,7 +389,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowQuickCommitFileDetailsCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyShowQuickCommitFileDetailsCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
lens.command = {
title: title,
command: commit !== undefined && commit.isUncommitted ? '' : CodeLensCommand.ShowQuickCommitFileDetails,
@@ -403,7 +403,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowQuickFileHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyShowQuickFileHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
lens.command = {
title: title,
command: CodeLensCommand.ShowQuickFileHistory,
@@ -417,7 +417,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowQuickBranchHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
_applyShowQuickBranchHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T {
lens.command = {
title: title,
command: CodeLensCommand.ShowQuickCurrentBranchHistory,

View File

@@ -4,7 +4,7 @@ import { Disposable, Event, EventEmitter, ExtensionContext, FileSystemWatcher, l
import { CommandContext, setCommandContext } from './commands';
import { IConfig } from './configuration';
import { DocumentSchemes, ExtensionKey } from './constants';
import { Git, GitBlameParser, GitBranch, GitCommit, GitDiffParser, GitLogCommit, GitLogParser, GitRemote, GitStashParser, GitStatusFile, GitStatusParser, IGit, IGitAuthor, IGitBlame, IGitBlameLine, IGitBlameLines, IGitDiff, IGitDiffLine, IGitLog, IGitStash, IGitStatus, setDefaultEncoding } from './git/git';
import { Git, GitAuthor, GitBlame, GitBlameLine, GitBlameLines, GitBlameParser, GitBranch, GitCommit, GitDiff, GitDiffLine, GitDiffParser, GitLog, GitLogCommit, GitLogParser, GitRemote, GitStash, GitStashParser, GitStatus, GitStatusFile, GitStatusParser, IGit, setDefaultEncoding } from './git/git';
import { GitUri, IGitCommitInfo, IGitUriData } from './git/gitUri';
import { GitCodeLensProvider } from './gitCodeLensProvider';
import { Logger } from './logger';
@@ -26,7 +26,7 @@ class UriCacheEntry {
class GitCacheEntry {
private cache: Map<string, ICachedBlame | ICachedDiff | ICachedLog> = new Map();
private cache: Map<string, CachedBlame | CachedDiff | CachedLog> = new Map();
constructor(public key: string) { }
@@ -34,23 +34,23 @@ class GitCacheEntry {
return Iterables.every(this.cache.values(), _ => _.errorMessage !== undefined);
}
get<T extends ICachedBlame | ICachedDiff | ICachedLog>(key: string): T | undefined {
get<T extends CachedBlame | CachedDiff | CachedLog>(key: string): T | undefined {
return this.cache.get(key) as T;
}
set<T extends ICachedBlame | ICachedDiff | ICachedLog>(key: string, value: T) {
set<T extends CachedBlame | CachedDiff | CachedLog>(key: string, value: T) {
this.cache.set(key, value);
}
}
interface ICachedItem<T> {
interface CachedItem<T> {
item: Promise<T>;
errorMessage?: string;
}
interface ICachedBlame extends ICachedItem<IGitBlame> { }
interface ICachedDiff extends ICachedItem<IGitDiff> { }
interface ICachedLog extends ICachedItem<IGitLog> { }
interface CachedBlame extends CachedItem<GitBlame> { }
interface CachedDiff extends CachedItem<GitDiff> { }
interface CachedLog extends CachedItem<GitLog> { }
enum RemoveCacheReason {
DocumentClosed,
@@ -89,7 +89,7 @@ export class GitService extends Disposable {
private _fsWatcher: FileSystemWatcher | undefined;
private _gitignore: Promise<ignore.Ignore>;
static EmptyPromise: Promise<IGitBlame | IGitDiff | IGitLog | undefined> = Promise.resolve(undefined);
static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
constructor(private context: ExtensionContext, public repoPath: string) {
super(() => this.dispose());
@@ -338,7 +338,7 @@ export class GitService extends Disposable {
return !entry.hasErrors;
}
async getBlameForFile(uri: GitUri): Promise<IGitBlame | undefined> {
async getBlameForFile(uri: GitUri): Promise<GitBlame | undefined> {
let key = 'blame';
if (uri.sha !== undefined) {
key += `:${uri.sha}`;
@@ -350,7 +350,7 @@ export class GitService extends Disposable {
entry = this._gitCache.get(cacheKey);
if (entry !== undefined) {
const cachedBlame = entry.get<ICachedBlame>(key);
const cachedBlame = entry.get<CachedBlame>(key);
if (cachedBlame !== undefined) {
Logger.log(`Cached(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`);
return cachedBlame.item;
@@ -373,15 +373,15 @@ export class GitService extends Disposable {
if (entry) {
Logger.log(`Add blame cache for '${entry.key}:${key}'`);
entry.set<ICachedBlame>(key, {
entry.set<CachedBlame>(key, {
item: promise
} as ICachedBlame);
} as CachedBlame);
}
return promise;
}
private async _getBlameForFile(uri: GitUri, entry: GitCacheEntry | undefined, key: string): Promise<IGitBlame | undefined> {
private async _getBlameForFile(uri: GitUri, entry: GitCacheEntry | undefined, key: string): Promise<GitBlame | undefined> {
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
const ignore = await this._gitignore;
@@ -390,7 +390,7 @@ export class GitService extends Disposable {
if (entry && entry.key) {
this._onDidBlameFail.fire(entry.key);
}
return await GitService.EmptyPromise as IGitBlame;
return await GitService.EmptyPromise as GitBlame;
}
try {
@@ -403,20 +403,20 @@ export class GitService extends Disposable {
const msg = ex && ex.toString();
Logger.log(`Replace blame cache with empty promise for '${entry.key}:${key}'`);
entry.set<ICachedBlame>(key, {
entry.set<CachedBlame>(key, {
item: GitService.EmptyPromise,
errorMessage: msg
} as ICachedBlame);
} as CachedBlame);
this._onDidBlameFail.fire(entry.key);
return await GitService.EmptyPromise as IGitBlame;
return await GitService.EmptyPromise as GitBlame;
}
return undefined;
}
}
async getBlameForLine(uri: GitUri, line: number): Promise<IGitBlameLine | undefined> {
async getBlameForLine(uri: GitUri, line: number): Promise<GitBlameLine | undefined> {
Logger.log(`getBlameForLine('${uri.repoPath}', '${uri.fsPath}', ${line}, ${uri.sha})`);
if (this.UseCaching) {
@@ -436,7 +436,7 @@ export class GitService extends Disposable {
author: Object.assign({}, blame.authors.get(commit.author), { lineCount: commit.lines.length }),
commit: commit,
line: blameLine
} as IGitBlameLine;
} as GitBlameLine;
}
const fileName = uri.fsPath;
@@ -454,14 +454,14 @@ export class GitService extends Disposable {
author: Iterables.first(blame.authors.values()),
commit: commit,
line: blame.lines[line]
} as IGitBlameLine;
} as GitBlameLine;
}
catch (ex) {
return undefined;
}
}
async getBlameForRange(uri: GitUri, range: Range): Promise<IGitBlameLines | undefined> {
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlameLines | undefined> {
Logger.log(`getBlameForRange('${uri.repoPath}', '${uri.fsPath}', [${range.start.line}, ${range.end.line}], ${uri.sha})`);
const blame = await this.getBlameForFile(uri);
@@ -470,7 +470,7 @@ export class GitService extends Disposable {
return this.getBlameForRangeSync(blame, uri, range);
}
getBlameForRangeSync(blame: IGitBlame, uri: GitUri, range: Range): IGitBlameLines | undefined {
getBlameForRangeSync(blame: GitBlame, uri: GitUri, range: Range): GitBlameLines | undefined {
Logger.log(`getBlameForRangeSync('${uri.repoPath}', '${uri.fsPath}', [${range.start.line}, ${range.end.line}], ${uri.sha})`);
if (blame.lines.length === 0) return Object.assign({ allLines: blame.lines }, blame);
@@ -483,7 +483,7 @@ export class GitService extends Disposable {
const shas: Set<string> = new Set();
lines.forEach(l => shas.add(l.sha));
const authors: Map<string, IGitAuthor> = new Map();
const authors: Map<string, GitAuthor> = new Map();
const commits: Map<string, GitCommit> = new Map();
blame.commits.forEach(c => {
if (!shas.has(c.sha)) return;
@@ -504,7 +504,7 @@ export class GitService extends Disposable {
author.lineCount += commit.lines.length;
});
const sortedAuthors: Map<string, IGitAuthor> = new Map();
const sortedAuthors: Map<string, GitAuthor> = new Map();
Array.from(authors.values())
.sort((a, b) => b.lineCount - a.lineCount)
.forEach(a => sortedAuthors.set(a.name, a));
@@ -514,7 +514,7 @@ export class GitService extends Disposable {
commits: commits,
lines: lines,
allLines: blame.lines
} as IGitBlameLines;
} as GitBlameLines;
}
async getBlameLocations(uri: GitUri, range: Range, selectedSha?: string, line?: number): Promise<Location[] | undefined> {
@@ -574,7 +574,7 @@ export class GitService extends Disposable {
return entry && entry.uri;
}
async getDiffForFile(uri: GitUri, sha1?: string, sha2?: string): Promise<IGitDiff | undefined> {
async getDiffForFile(uri: GitUri, sha1?: string, sha2?: string): Promise<GitDiff | undefined> {
if (sha1 !== undefined && sha2 === undefined && uri.sha !== undefined) {
sha2 = uri.sha;
}
@@ -593,7 +593,7 @@ export class GitService extends Disposable {
entry = this._gitCache.get(cacheKey);
if (entry !== undefined) {
const cachedDiff = entry.get<ICachedDiff>(key);
const cachedDiff = entry.get<CachedDiff>(key);
if (cachedDiff !== undefined) {
Logger.log(`Cached(${key}): getDiffForFile('${uri.repoPath}', '${uri.fsPath}', ${sha1}, ${sha2})`);
return cachedDiff.item;
@@ -616,15 +616,15 @@ export class GitService extends Disposable {
if (entry) {
Logger.log(`Add log cache for '${entry.key}:${key}'`);
entry.set<ICachedDiff>(key, {
entry.set<CachedDiff>(key, {
item: promise
} as ICachedDiff);
} as CachedDiff);
}
return promise;
}
private async _getDiffForFile(repoPath: string | undefined, fileName: string, sha1: string | undefined, sha2: string | undefined, entry: GitCacheEntry | undefined, key: string): Promise<IGitDiff | undefined> {
private async _getDiffForFile(repoPath: string | undefined, fileName: string, sha1: string | undefined, sha2: string | undefined, entry: GitCacheEntry | undefined, key: string): Promise<GitDiff | undefined> {
const [file, root] = Git.splitPath(fileName, repoPath, false);
try {
@@ -637,19 +637,19 @@ export class GitService extends Disposable {
const msg = ex && ex.toString();
Logger.log(`Replace diff cache with empty promise for '${entry.key}:${key}'`);
entry.set<ICachedDiff>(key, {
entry.set<CachedDiff>(key, {
item: GitService.EmptyPromise,
errorMessage: msg
} as ICachedDiff);
} as CachedDiff);
return await GitService.EmptyPromise as IGitDiff;
return await GitService.EmptyPromise as GitDiff;
}
return undefined;
}
}
async getDiffForLine(uri: GitUri, line: number, sha1?: string, sha2?: string): Promise<[IGitDiffLine | undefined, IGitDiffLine | undefined]> {
async getDiffForLine(uri: GitUri, line: number, sha1?: string, sha2?: string): Promise<[GitDiffLine | undefined, GitDiffLine | undefined]> {
try {
const diff = await this.getDiffForFile(uri, sha1, sha2);
if (diff === undefined) return [undefined, undefined];
@@ -706,7 +706,7 @@ export class GitService extends Disposable {
return commit || Iterables.first(log.commits.values());
}
async getLogForRepo(repoPath: string, sha?: string, maxCount?: number, reverse: boolean = false): Promise<IGitLog | undefined> {
async getLogForRepo(repoPath: string, sha?: string, maxCount?: number, reverse: boolean = false): Promise<GitLog | undefined> {
Logger.log(`getLogForRepo('${repoPath}', ${sha}, ${maxCount})`);
if (maxCount == null) {
@@ -722,7 +722,7 @@ export class GitService extends Disposable {
}
}
async getLogForRepoSearch(repoPath: string, search: string, searchBy: GitRepoSearchBy, maxCount?: number): Promise<IGitLog | undefined> {
async getLogForRepoSearch(repoPath: string, search: string, searchBy: GitRepoSearchBy, maxCount?: number): Promise<GitLog | undefined> {
Logger.log(`getLogForRepoSearch('${repoPath}', ${search}, ${searchBy}, ${maxCount})`);
if (maxCount == null) {
@@ -755,7 +755,7 @@ export class GitService extends Disposable {
}
}
async getLogForFile(repoPath: string | undefined, fileName: string, sha?: string, maxCount?: number, range?: Range, reverse: boolean = false): Promise<IGitLog | undefined> {
async getLogForFile(repoPath: string | undefined, fileName: string, sha?: string, maxCount?: number, range?: Range, reverse: boolean = false): Promise<GitLog | undefined> {
let key = 'log';
if (sha !== undefined) {
key += `:${sha}`;
@@ -770,7 +770,7 @@ export class GitService extends Disposable {
entry = this._gitCache.get(cacheKey);
if (entry !== undefined) {
const cachedLog = entry.get<ICachedLog>(key);
const cachedLog = entry.get<CachedLog>(key);
if (cachedLog !== undefined) {
Logger.log(`Cached(${key}): getLogForFile('${repoPath}', '${fileName}', ${sha}, ${maxCount}, undefined, false)`);
return cachedLog.item;
@@ -778,7 +778,7 @@ export class GitService extends Disposable {
if (key !== 'log') {
// Since we are looking for partial log, see if we have the log of the whole file
const cachedLog = entry.get<ICachedLog>('log');
const cachedLog = entry.get<CachedLog>('log');
if (cachedLog !== undefined) {
if (sha === undefined) {
Logger.log(`Cached(~${key}): getLogForFile('${repoPath}', '${fileName}', ${sha}, ${maxCount}, undefined, false)`);
@@ -811,21 +811,21 @@ export class GitService extends Disposable {
if (entry) {
Logger.log(`Add log cache for '${entry.key}:${key}'`);
entry.set<ICachedLog>(key, {
entry.set<CachedLog>(key, {
item: promise
} as ICachedLog);
} as CachedLog);
}
return promise;
}
private async _getLogForFile(repoPath: string | undefined, fileName: string, sha: string | undefined, range: Range | undefined, maxCount: number | undefined, reverse: boolean, entry: GitCacheEntry | undefined, key: string): Promise<IGitLog | undefined> {
private async _getLogForFile(repoPath: string | undefined, fileName: string, sha: string | undefined, range: Range | undefined, maxCount: number | undefined, reverse: boolean, entry: GitCacheEntry | undefined, key: string): Promise<GitLog | undefined> {
const [file, root] = Git.splitPath(fileName, repoPath, false);
const ignore = await this._gitignore;
if (ignore && !ignore.filter([file]).length) {
Logger.log(`Skipping log; '${fileName}' is gitignored`);
return await GitService.EmptyPromise as IGitLog;
return await GitService.EmptyPromise as GitLog;
}
try {
@@ -838,12 +838,12 @@ export class GitService extends Disposable {
const msg = ex && ex.toString();
Logger.log(`Replace log cache with empty promise for '${entry.key}:${key}'`);
entry.set<ICachedLog>(key, {
entry.set<CachedLog>(key, {
item: GitService.EmptyPromise,
errorMessage: msg
} as ICachedLog);
} as CachedLog);
return await GitService.EmptyPromise as IGitLog;
return await GitService.EmptyPromise as GitLog;
}
return undefined;
@@ -911,7 +911,7 @@ export class GitService extends Disposable {
return repoPath;
}
async getStashList(repoPath: string): Promise<IGitStash | undefined> {
async getStashList(repoPath: string): Promise<GitStash | undefined> {
Logger.log(`getStash('${repoPath}')`);
const data = await Git.stash_list(repoPath);
@@ -930,7 +930,7 @@ export class GitService extends Disposable {
return status.files[0];
}
async getStatusForRepo(repoPath: string): Promise<IGitStatus | undefined> {
async getStatusForRepo(repoPath: string): Promise<GitStatus | undefined> {
Logger.log(`getStatusForRepo('${repoPath}')`);
const porcelainVersion = Git.validateVersion(2, 11) ? 2 : 1;

View File

@@ -3,7 +3,7 @@ import { Arrays, Iterables } from '../system';
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand, ShowCommitSearchCommandArgs, ShowQuickBranchHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common';
import { GitService, GitUri, IGitLog, RemoteResource } from '../gitService';
import { GitLog, GitService, GitUri, RemoteResource } from '../gitService';
import { OpenRemotesCommandQuickPickItem } from './remotes';
export class BranchHistoryQuickPick {
@@ -17,7 +17,7 @@ export class BranchHistoryQuickPick {
});
}
static async show(git: GitService, log: IGitLog, uri: GitUri | undefined, branch: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, log: GitLog, uri: GitUri | undefined, branch: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
const currentCommand = new CommandQuickPickItem({

View File

@@ -3,7 +3,7 @@ import { Arrays, Iterables } from '../system';
import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, DiffWithPreviousCommandArgs, Keyboard, KeyNoopCommand, Keys, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem } from './common';
import { getGitStatusIcon, GitCommit, GitLogCommit, GitService, GitStashCommit, GitStatusFileStatus, GitUri, IGitCommitInfo, IGitLog, IGitStatusFile, RemoteResource } from '../gitService';
import { getGitStatusIcon, GitCommit, GitLog, GitLogCommit, GitService, GitStashCommit, GitStatusFileStatus, GitUri, IGitCommitInfo, IGitStatusFile, RemoteResource } from '../gitService';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment';
import * as path from 'path';
@@ -103,7 +103,7 @@ export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCom
export class CommitDetailsQuickPick {
static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, repoLog?: IGitLog): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, repoLog?: GitLog): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs));
const stash = commit.type === 'stash';

View File

@@ -3,7 +3,7 @@ import { Arrays, Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, Keyboard, KeyNoopCommand, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './common';
import { GitBranch, GitLogCommit, GitService, GitUri, IGitLog, RemoteResource } from '../gitService';
import { GitBranch, GitLog, GitLogCommit, GitService, GitUri, RemoteResource } from '../gitService';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment';
import * as path from 'path';
@@ -41,7 +41,7 @@ export class OpenCommitWorkingTreeFileCommandQuickPickItem extends OpenFileComma
export class CommitFileDetailsQuickPick {
static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, fileLog?: IGitLog): Promise<CommandQuickPickItem | undefined> {
static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, fileLog?: GitLog): Promise<CommandQuickPickItem | undefined> {
const items: CommandQuickPickItem[] = [];
const stash = commit.type === 'stash';

View File

@@ -2,12 +2,12 @@
import { Iterables } from '../system';
import { QuickPickOptions, window } from 'vscode';
import { Keyboard } from '../commands';
import { GitService, IGitLog } from '../gitService';
import { GitLog, GitService } from '../gitService';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks';
export class CommitsQuickPick {
static async show(git: GitService, log: IGitLog, placeHolder: string, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, log: GitLog, placeHolder: string, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = ((log && Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (goBackCommand) {

View File

@@ -3,7 +3,7 @@ import { Arrays, Iterables } from '../system';
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand, ShowQuickCurrentBranchHistoryCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common';
import { GitService, GitUri, IGitLog, RemoteResource } from '../gitService';
import { GitLog, GitService, GitUri, RemoteResource } from '../gitService';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as path from 'path';
@@ -18,7 +18,7 @@ export class FileHistoryQuickPick {
});
}
static async show(git: GitService, log: IGitLog, uri: GitUri, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, log: GitLog, uri: GitUri, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
let previousPageCommand: CommandQuickPickItem | undefined = undefined;

View File

@@ -3,7 +3,7 @@ import { Iterables } from '../system';
import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, DiffWithWorkingCommandArgs, Keyboard, Keys, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './common';
import { GitService, GitStatusFile, GitUri, IGitStatus } from '../gitService';
import { GitService, GitStatus, GitStatusFile, GitUri } from '../gitService';
import * as path from 'path';
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
@@ -58,7 +58,7 @@ export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem {
export class RepoStatusQuickPick {
static async show(status: IGitStatus, goBackCommand?: CommandQuickPickItem): Promise<OpenStatusFileCommandQuickPickItem | OpenStatusFilesCommandQuickPickItem | CommandQuickPickItem | undefined> {
static async show(status: GitStatus, goBackCommand?: CommandQuickPickItem): Promise<OpenStatusFileCommandQuickPickItem | OpenStatusFilesCommandQuickPickItem | CommandQuickPickItem | undefined> {
// Sort the status by staged and then filename
const files = status.files;
files.sort((a, b) => (a.staged ? -1 : 1) - (b.staged ? -1 : 1) || a.fileName.localeCompare(b.fileName));

View File

@@ -2,12 +2,12 @@
import { Iterables } from '../system';
import { QuickPickOptions, window } from 'vscode';
import { Commands, Keyboard, StashSaveCommandArgs } from '../commands';
import { GitService, IGitStash } from '../gitService';
import { GitService, GitStash } from '../gitService';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks';
export class StashListQuickPick {
static async show(git: GitService, stash: IGitStash, mode: 'list' | 'apply', goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, stash: GitStash, mode: 'list' | 'apply', goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (mode === 'list') {