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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { Strings } from '../../system'; import { Strings } from '../../system';
import { GitCommit } from '../models/commit'; import { GitCommit } from '../models/commit';
import { IGitDiffLine } from '../models/diff'; import { GitDiffLine } from '../models/diff';
import * as moment from 'moment'; import * as moment from 'moment';
export interface ICommitFormatOptions { 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}`; 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; if (previous === undefined && current === undefined) return undefined;
const codeDiff = this._getCodeDiff(previous, current); const codeDiff = this._getCodeDiff(previous, current);
@@ -151,7 +151,7 @@ export class CommitFormatter {
: `\`Changes\` &nbsp; \u2014 &nbsp; \`${commit.previousShortSha}\` \u2194 \`${commit.shortSha}\`\n${codeDiff}`; : `\`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 `\`\`\` return `\`\`\`
- ${previous === undefined ? '' : previous.line.trim()} - ${previous === undefined ? '' : previous.line.trim()}
+ ${current === undefined ? '' : current.line.trim()} + ${current === undefined ? '' : current.line.trim()}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { Git, GitStatusFile, GitStatusFileStatus, IGitStatus } from './../git'; import { Git, GitStatus, GitStatusFile, GitStatusFileStatus } from './../git';
interface IFileStatusEntry { interface FileStatusEntry {
staged: boolean; staged: boolean;
status: GitStatusFileStatus; status: GitStatusFileStatus;
fileName: string; fileName: string;
@@ -13,7 +13,7 @@ const behindStatusV1Regex = /(?:behind ([0-9]+))/;
export class GitStatusParser { 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; if (!data) return undefined;
const lines = data.split('\n').filter(_ => !!_); const lines = data.split('\n').filter(_ => !!_);
@@ -40,7 +40,7 @@ export class GitStatusParser {
return status; return status;
} }
private static _parseV1(lines: string[], repoPath: string, status: IGitStatus) { private static _parseV1(lines: string[], repoPath: string, status: GitStatus) {
let position = -1; let position = -1;
while (++position < lines.length) { while (++position < lines.length) {
const line = lines[position]; const line = lines[position];
@@ -59,7 +59,7 @@ export class GitStatusParser {
} }
} }
else { else {
let entry: IFileStatusEntry; let entry: FileStatusEntry;
const rawStatus = line.substring(0, 2); const rawStatus = line.substring(0, 2);
const fileName = line.substring(3); const fileName = line.substring(3);
if (rawStatus[0] === 'R') { 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; let position = -1;
while (++position < lines.length) { while (++position < lines.length) {
const line = lines[position]; const line = lines[position];
@@ -99,7 +99,7 @@ export class GitStatusParser {
} }
else { else {
const lineParts = line.split(' '); const lineParts = line.split(' ');
let entry: IFileStatusEntry | undefined = undefined; let entry: FileStatusEntry | undefined = undefined;
switch (lineParts[0][0]) { switch (lineParts[0][0]) {
case '1': // normal case '1': // normal
entry = this._parseFileEntry(lineParts[1], lineParts.slice(8).join(' ')); 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 indexStatus = rawStatus[0] !== '.' ? rawStatus[0].trim() : undefined;
const workTreeStatus = rawStatus[1] !== '.' ? rawStatus[1].trim() : undefined; const workTreeStatus = rawStatus[1] !== '.' ? rawStatus[1].trim() : undefined;
@@ -132,6 +132,6 @@ export class GitStatusParser {
fileName: fileName, fileName: fileName,
originalFileName: originalFileName, originalFileName: originalFileName,
staged: !!indexStatus 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 { Commands, DiffWithPreviousCommandArgs, ShowBlameHistoryCommandArgs, ShowFileHistoryCommandArgs, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from './commands';
import { BuiltInCommands, DocumentSchemes, ExtensionKey } from './constants'; import { BuiltInCommands, DocumentSchemes, ExtensionKey } from './constants';
import { CodeLensCommand, CodeLensLocations, ICodeLensLanguageLocation, IConfig } from './configuration'; 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 { Logger } from './logger';
import * as moment from 'moment'; import * as moment from 'moment';
export class GitRecentChangeCodeLens extends CodeLens { 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); super(range);
} }
getBlame(): IGitBlameLines | undefined { getBlame(): GitBlameLines | undefined {
return this.blame(); return this.blame();
} }
} }
export class GitAuthorsCodeLens extends CodeLens { 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); super(range);
} }
getBlame(): IGitBlameLines | undefined { getBlame(): GitBlameLines | undefined {
return this.blame(); return this.blame();
} }
} }
@@ -70,7 +70,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
const gitUri = await GitUri.fromUri(document.uri, this.git); const gitUri = await GitUri.fromUri(document.uri, this.git);
const blamePromise = this.git.getBlameForFile(gitUri); const blamePromise = this.git.getBlameForFile(gitUri);
let blame: IGitBlame | undefined; let blame: GitBlame | undefined;
if (languageLocations.locations.length === 1 && languageLocations.locations.includes(CodeLensLocations.Document)) { if (languageLocations.locations.length === 1 && languageLocations.locations.includes(CodeLensLocations.Document)) {
blame = await blamePromise; blame = await blamePromise;
if (blame === undefined || !blame.lines.length) return lenses; 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> 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; if (blame === undefined || !blame.lines.length) return lenses;
const symbols = values[1] as SymbolInformation[]; 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 // 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)) { if (!lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0)) {
const blameRange = document.validateRange(new Range(0, 1000000, 1000000, 1000000)); 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) { if (this._documentIsDirty || this._config.codeLens.recentChange.enabled) {
blameForRangeFn = Functions.once(() => this.git.getBlameForRangeSync(blame!, gitUri, blameRange)); 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))); 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; 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); const blameRange = this._validateSymbolAndGetBlameRange(document, symbol, languageLocation);
if (!blameRange) return; 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 // Anchor the code lens to the end of the line -- so they are somewhat consistenly placed
let startChar = line.range.end.character - 1; 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) { if (this._documentIsDirty || this._config.codeLens.recentChange.enabled) {
blameForRangeFn = Functions.once(() => this.git.getBlameForRangeSync(blame, gitUri, blameRange)); 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)))); 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()); const recentCommit = Iterables.first(blame.commits.values());
title = `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`; title = `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`;
if (this._config.codeLens.debug) { 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) { switch (this._config.codeLens.recentChange.command) {
@@ -279,7 +279,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
const count = blame.authors.size; const count = blame.authors.size;
let title = `${count} ${count > 1 ? 'authors' : 'author'} (${Iterables.first(blame.authors.values()).name}${count > 1 ? ' and others' : ''})`; let title = `${count} ${count > 1 ? 'authors' : 'author'} (${Iterables.first(blame.authors.values()).name}${count > 1 ? ' and others' : ''})`;
if (this._config.codeLens.debug) { 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) { 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 = { lens.command = {
title: title, title: title,
command: Commands.ToggleFileBlame, command: Commands.ToggleFileBlame,
@@ -304,7 +304,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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; let line = lens.range.start.line;
if (commit) { if (commit) {
const blameLine = commit.lines.find(_ => _.line === line); const blameLine = commit.lines.find(_ => _.line === line);
@@ -330,7 +330,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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; let line = lens.range.start.line;
if (commit) { if (commit) {
const blameLine = commit.lines.find(_ => _.line === line); const blameLine = commit.lines.find(_ => _.line === line);
@@ -355,7 +355,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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) { if (commit === undefined) {
const blameLine = blame.allLines[lens.range.start.line]; const blameLine = blame.allLines[lens.range.start.line];
commit = blame.commits.get(blameLine.sha); commit = blame.commits.get(blameLine.sha);
@@ -375,7 +375,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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 = { lens.command = {
title: title, title: title,
command: commit !== undefined && commit.isUncommitted ? '' : CodeLensCommand.ShowQuickCommitDetails, command: commit !== undefined && commit.isUncommitted ? '' : CodeLensCommand.ShowQuickCommitDetails,
@@ -389,7 +389,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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 = { lens.command = {
title: title, title: title,
command: commit !== undefined && commit.isUncommitted ? '' : CodeLensCommand.ShowQuickCommitFileDetails, command: commit !== undefined && commit.isUncommitted ? '' : CodeLensCommand.ShowQuickCommitFileDetails,
@@ -403,7 +403,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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 = { lens.command = {
title: title, title: title,
command: CodeLensCommand.ShowQuickFileHistory, command: CodeLensCommand.ShowQuickFileHistory,
@@ -417,7 +417,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lens; 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 = { lens.command = {
title: title, title: title,
command: CodeLensCommand.ShowQuickCurrentBranchHistory, command: CodeLensCommand.ShowQuickCurrentBranchHistory,

View File

@@ -4,7 +4,7 @@ import { Disposable, Event, EventEmitter, ExtensionContext, FileSystemWatcher, l
import { CommandContext, setCommandContext } from './commands'; import { CommandContext, setCommandContext } from './commands';
import { IConfig } from './configuration'; import { IConfig } from './configuration';
import { DocumentSchemes, ExtensionKey } from './constants'; 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 { GitUri, IGitCommitInfo, IGitUriData } from './git/gitUri';
import { GitCodeLensProvider } from './gitCodeLensProvider'; import { GitCodeLensProvider } from './gitCodeLensProvider';
import { Logger } from './logger'; import { Logger } from './logger';
@@ -26,7 +26,7 @@ class UriCacheEntry {
class GitCacheEntry { class GitCacheEntry {
private cache: Map<string, ICachedBlame | ICachedDiff | ICachedLog> = new Map(); private cache: Map<string, CachedBlame | CachedDiff | CachedLog> = new Map();
constructor(public key: string) { } constructor(public key: string) { }
@@ -34,23 +34,23 @@ class GitCacheEntry {
return Iterables.every(this.cache.values(), _ => _.errorMessage !== undefined); 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; 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); this.cache.set(key, value);
} }
} }
interface ICachedItem<T> { interface CachedItem<T> {
item: Promise<T>; item: Promise<T>;
errorMessage?: string; errorMessage?: string;
} }
interface ICachedBlame extends ICachedItem<IGitBlame> { } interface CachedBlame extends CachedItem<GitBlame> { }
interface ICachedDiff extends ICachedItem<IGitDiff> { } interface CachedDiff extends CachedItem<GitDiff> { }
interface ICachedLog extends ICachedItem<IGitLog> { } interface CachedLog extends CachedItem<GitLog> { }
enum RemoveCacheReason { enum RemoveCacheReason {
DocumentClosed, DocumentClosed,
@@ -89,7 +89,7 @@ export class GitService extends Disposable {
private _fsWatcher: FileSystemWatcher | undefined; private _fsWatcher: FileSystemWatcher | undefined;
private _gitignore: Promise<ignore.Ignore>; 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) { constructor(private context: ExtensionContext, public repoPath: string) {
super(() => this.dispose()); super(() => this.dispose());
@@ -338,7 +338,7 @@ export class GitService extends Disposable {
return !entry.hasErrors; return !entry.hasErrors;
} }
async getBlameForFile(uri: GitUri): Promise<IGitBlame | undefined> { async getBlameForFile(uri: GitUri): Promise<GitBlame | undefined> {
let key = 'blame'; let key = 'blame';
if (uri.sha !== undefined) { if (uri.sha !== undefined) {
key += `:${uri.sha}`; key += `:${uri.sha}`;
@@ -350,7 +350,7 @@ export class GitService extends Disposable {
entry = this._gitCache.get(cacheKey); entry = this._gitCache.get(cacheKey);
if (entry !== undefined) { if (entry !== undefined) {
const cachedBlame = entry.get<ICachedBlame>(key); const cachedBlame = entry.get<CachedBlame>(key);
if (cachedBlame !== undefined) { if (cachedBlame !== undefined) {
Logger.log(`Cached(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`); Logger.log(`Cached(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`);
return cachedBlame.item; return cachedBlame.item;
@@ -373,15 +373,15 @@ export class GitService extends Disposable {
if (entry) { if (entry) {
Logger.log(`Add blame cache for '${entry.key}:${key}'`); Logger.log(`Add blame cache for '${entry.key}:${key}'`);
entry.set<ICachedBlame>(key, { entry.set<CachedBlame>(key, {
item: promise item: promise
} as ICachedBlame); } as CachedBlame);
} }
return promise; 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 [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
const ignore = await this._gitignore; const ignore = await this._gitignore;
@@ -390,7 +390,7 @@ export class GitService extends Disposable {
if (entry && entry.key) { if (entry && entry.key) {
this._onDidBlameFail.fire(entry.key); this._onDidBlameFail.fire(entry.key);
} }
return await GitService.EmptyPromise as IGitBlame; return await GitService.EmptyPromise as GitBlame;
} }
try { try {
@@ -403,20 +403,20 @@ export class GitService extends Disposable {
const msg = ex && ex.toString(); const msg = ex && ex.toString();
Logger.log(`Replace blame cache with empty promise for '${entry.key}:${key}'`); Logger.log(`Replace blame cache with empty promise for '${entry.key}:${key}'`);
entry.set<ICachedBlame>(key, { entry.set<CachedBlame>(key, {
item: GitService.EmptyPromise, item: GitService.EmptyPromise,
errorMessage: msg errorMessage: msg
} as ICachedBlame); } as CachedBlame);
this._onDidBlameFail.fire(entry.key); this._onDidBlameFail.fire(entry.key);
return await GitService.EmptyPromise as IGitBlame; return await GitService.EmptyPromise as GitBlame;
} }
return undefined; 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})`); Logger.log(`getBlameForLine('${uri.repoPath}', '${uri.fsPath}', ${line}, ${uri.sha})`);
if (this.UseCaching) { if (this.UseCaching) {
@@ -436,7 +436,7 @@ export class GitService extends Disposable {
author: Object.assign({}, blame.authors.get(commit.author), { lineCount: commit.lines.length }), author: Object.assign({}, blame.authors.get(commit.author), { lineCount: commit.lines.length }),
commit: commit, commit: commit,
line: blameLine line: blameLine
} as IGitBlameLine; } as GitBlameLine;
} }
const fileName = uri.fsPath; const fileName = uri.fsPath;
@@ -454,14 +454,14 @@ export class GitService extends Disposable {
author: Iterables.first(blame.authors.values()), author: Iterables.first(blame.authors.values()),
commit: commit, commit: commit,
line: blame.lines[line] line: blame.lines[line]
} as IGitBlameLine; } as GitBlameLine;
} }
catch (ex) { catch (ex) {
return undefined; 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})`); Logger.log(`getBlameForRange('${uri.repoPath}', '${uri.fsPath}', [${range.start.line}, ${range.end.line}], ${uri.sha})`);
const blame = await this.getBlameForFile(uri); const blame = await this.getBlameForFile(uri);
@@ -470,7 +470,7 @@ export class GitService extends Disposable {
return this.getBlameForRangeSync(blame, uri, range); 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})`); 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); 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(); const shas: Set<string> = new Set();
lines.forEach(l => shas.add(l.sha)); 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(); const commits: Map<string, GitCommit> = new Map();
blame.commits.forEach(c => { blame.commits.forEach(c => {
if (!shas.has(c.sha)) return; if (!shas.has(c.sha)) return;
@@ -504,7 +504,7 @@ export class GitService extends Disposable {
author.lineCount += commit.lines.length; author.lineCount += commit.lines.length;
}); });
const sortedAuthors: Map<string, IGitAuthor> = new Map(); const sortedAuthors: Map<string, GitAuthor> = new Map();
Array.from(authors.values()) Array.from(authors.values())
.sort((a, b) => b.lineCount - a.lineCount) .sort((a, b) => b.lineCount - a.lineCount)
.forEach(a => sortedAuthors.set(a.name, a)); .forEach(a => sortedAuthors.set(a.name, a));
@@ -514,7 +514,7 @@ export class GitService extends Disposable {
commits: commits, commits: commits,
lines: lines, lines: lines,
allLines: blame.lines allLines: blame.lines
} as IGitBlameLines; } as GitBlameLines;
} }
async getBlameLocations(uri: GitUri, range: Range, selectedSha?: string, line?: number): Promise<Location[] | undefined> { 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; 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) { if (sha1 !== undefined && sha2 === undefined && uri.sha !== undefined) {
sha2 = uri.sha; sha2 = uri.sha;
} }
@@ -593,7 +593,7 @@ export class GitService extends Disposable {
entry = this._gitCache.get(cacheKey); entry = this._gitCache.get(cacheKey);
if (entry !== undefined) { if (entry !== undefined) {
const cachedDiff = entry.get<ICachedDiff>(key); const cachedDiff = entry.get<CachedDiff>(key);
if (cachedDiff !== undefined) { if (cachedDiff !== undefined) {
Logger.log(`Cached(${key}): getDiffForFile('${uri.repoPath}', '${uri.fsPath}', ${sha1}, ${sha2})`); Logger.log(`Cached(${key}): getDiffForFile('${uri.repoPath}', '${uri.fsPath}', ${sha1}, ${sha2})`);
return cachedDiff.item; return cachedDiff.item;
@@ -616,15 +616,15 @@ export class GitService extends Disposable {
if (entry) { if (entry) {
Logger.log(`Add log cache for '${entry.key}:${key}'`); Logger.log(`Add log cache for '${entry.key}:${key}'`);
entry.set<ICachedDiff>(key, { entry.set<CachedDiff>(key, {
item: promise item: promise
} as ICachedDiff); } as CachedDiff);
} }
return promise; 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); const [file, root] = Git.splitPath(fileName, repoPath, false);
try { try {
@@ -637,19 +637,19 @@ export class GitService extends Disposable {
const msg = ex && ex.toString(); const msg = ex && ex.toString();
Logger.log(`Replace diff cache with empty promise for '${entry.key}:${key}'`); Logger.log(`Replace diff cache with empty promise for '${entry.key}:${key}'`);
entry.set<ICachedDiff>(key, { entry.set<CachedDiff>(key, {
item: GitService.EmptyPromise, item: GitService.EmptyPromise,
errorMessage: msg errorMessage: msg
} as ICachedDiff); } as CachedDiff);
return await GitService.EmptyPromise as IGitDiff; return await GitService.EmptyPromise as GitDiff;
} }
return undefined; 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 { try {
const diff = await this.getDiffForFile(uri, sha1, sha2); const diff = await this.getDiffForFile(uri, sha1, sha2);
if (diff === undefined) return [undefined, undefined]; if (diff === undefined) return [undefined, undefined];
@@ -706,7 +706,7 @@ export class GitService extends Disposable {
return commit || Iterables.first(log.commits.values()); 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})`); Logger.log(`getLogForRepo('${repoPath}', ${sha}, ${maxCount})`);
if (maxCount == null) { 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})`); Logger.log(`getLogForRepoSearch('${repoPath}', ${search}, ${searchBy}, ${maxCount})`);
if (maxCount == null) { 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'; let key = 'log';
if (sha !== undefined) { if (sha !== undefined) {
key += `:${sha}`; key += `:${sha}`;
@@ -770,7 +770,7 @@ export class GitService extends Disposable {
entry = this._gitCache.get(cacheKey); entry = this._gitCache.get(cacheKey);
if (entry !== undefined) { if (entry !== undefined) {
const cachedLog = entry.get<ICachedLog>(key); const cachedLog = entry.get<CachedLog>(key);
if (cachedLog !== undefined) { if (cachedLog !== undefined) {
Logger.log(`Cached(${key}): getLogForFile('${repoPath}', '${fileName}', ${sha}, ${maxCount}, undefined, false)`); Logger.log(`Cached(${key}): getLogForFile('${repoPath}', '${fileName}', ${sha}, ${maxCount}, undefined, false)`);
return cachedLog.item; return cachedLog.item;
@@ -778,7 +778,7 @@ export class GitService extends Disposable {
if (key !== 'log') { if (key !== 'log') {
// Since we are looking for partial log, see if we have the log of the whole file // 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 (cachedLog !== undefined) {
if (sha === undefined) { if (sha === undefined) {
Logger.log(`Cached(~${key}): getLogForFile('${repoPath}', '${fileName}', ${sha}, ${maxCount}, undefined, false)`); Logger.log(`Cached(~${key}): getLogForFile('${repoPath}', '${fileName}', ${sha}, ${maxCount}, undefined, false)`);
@@ -811,21 +811,21 @@ export class GitService extends Disposable {
if (entry) { if (entry) {
Logger.log(`Add log cache for '${entry.key}:${key}'`); Logger.log(`Add log cache for '${entry.key}:${key}'`);
entry.set<ICachedLog>(key, { entry.set<CachedLog>(key, {
item: promise item: promise
} as ICachedLog); } as CachedLog);
} }
return promise; 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 [file, root] = Git.splitPath(fileName, repoPath, false);
const ignore = await this._gitignore; const ignore = await this._gitignore;
if (ignore && !ignore.filter([file]).length) { if (ignore && !ignore.filter([file]).length) {
Logger.log(`Skipping log; '${fileName}' is gitignored`); Logger.log(`Skipping log; '${fileName}' is gitignored`);
return await GitService.EmptyPromise as IGitLog; return await GitService.EmptyPromise as GitLog;
} }
try { try {
@@ -838,12 +838,12 @@ export class GitService extends Disposable {
const msg = ex && ex.toString(); const msg = ex && ex.toString();
Logger.log(`Replace log cache with empty promise for '${entry.key}:${key}'`); Logger.log(`Replace log cache with empty promise for '${entry.key}:${key}'`);
entry.set<ICachedLog>(key, { entry.set<CachedLog>(key, {
item: GitService.EmptyPromise, item: GitService.EmptyPromise,
errorMessage: msg errorMessage: msg
} as ICachedLog); } as CachedLog);
return await GitService.EmptyPromise as IGitLog; return await GitService.EmptyPromise as GitLog;
} }
return undefined; return undefined;
@@ -911,7 +911,7 @@ export class GitService extends Disposable {
return repoPath; return repoPath;
} }
async getStashList(repoPath: string): Promise<IGitStash | undefined> { async getStashList(repoPath: string): Promise<GitStash | undefined> {
Logger.log(`getStash('${repoPath}')`); Logger.log(`getStash('${repoPath}')`);
const data = await Git.stash_list(repoPath); const data = await Git.stash_list(repoPath);
@@ -930,7 +930,7 @@ export class GitService extends Disposable {
return status.files[0]; return status.files[0];
} }
async getStatusForRepo(repoPath: string): Promise<IGitStatus | undefined> { async getStatusForRepo(repoPath: string): Promise<GitStatus | undefined> {
Logger.log(`getStatusForRepo('${repoPath}')`); Logger.log(`getStatusForRepo('${repoPath}')`);
const porcelainVersion = Git.validateVersion(2, 11) ? 2 : 1; 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 { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand, ShowCommitSearchCommandArgs, ShowQuickBranchHistoryCommandArgs } from '../commands'; import { Commands, Keyboard, KeyNoopCommand, ShowCommitSearchCommandArgs, ShowQuickBranchHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common'; 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 { OpenRemotesCommandQuickPickItem } from './remotes';
export class BranchHistoryQuickPick { 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 items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
const currentCommand = new 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, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, DiffWithPreviousCommandArgs, Keyboard, KeyNoopCommand, Keys, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands'; import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, DiffWithPreviousCommandArgs, Keyboard, KeyNoopCommand, Keys, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem } from './common'; 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 { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment'; import * as moment from 'moment';
import * as path from 'path'; import * as path from 'path';
@@ -103,7 +103,7 @@ export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCom
export class CommitDetailsQuickPick { 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 items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs));
const stash = commit.type === 'stash'; const stash = commit.type === 'stash';

View File

@@ -3,7 +3,7 @@ import { Arrays, Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode'; import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, Keyboard, KeyNoopCommand, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands'; import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, Keyboard, KeyNoopCommand, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './common'; 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 { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment'; import * as moment from 'moment';
import * as path from 'path'; import * as path from 'path';
@@ -41,7 +41,7 @@ export class OpenCommitWorkingTreeFileCommandQuickPickItem extends OpenFileComma
export class CommitFileDetailsQuickPick { 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 items: CommandQuickPickItem[] = [];
const stash = commit.type === 'stash'; const stash = commit.type === 'stash';

View File

@@ -2,12 +2,12 @@
import { Iterables } from '../system'; import { Iterables } from '../system';
import { QuickPickOptions, window } from 'vscode'; import { QuickPickOptions, window } from 'vscode';
import { Keyboard } from '../commands'; import { Keyboard } from '../commands';
import { GitService, IGitLog } from '../gitService'; import { GitLog, GitService } from '../gitService';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks'; import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks';
export class CommitsQuickPick { 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)[]; const items = ((log && Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (goBackCommand) { if (goBackCommand) {

View File

@@ -3,7 +3,7 @@ import { Arrays, Iterables } from '../system';
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode'; import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand, ShowQuickCurrentBranchHistoryCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands'; import { Commands, Keyboard, KeyNoopCommand, ShowQuickCurrentBranchHistoryCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common'; 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 { OpenRemotesCommandQuickPickItem } from './remotes';
import * as path from 'path'; 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)[]; const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
let previousPageCommand: CommandQuickPickItem | undefined = undefined; 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, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, DiffWithWorkingCommandArgs, Keyboard, Keys, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands'; import { Commands, DiffWithWorkingCommandArgs, Keyboard, Keys, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './common'; 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'; import * as path from 'path';
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem { export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
@@ -58,7 +58,7 @@ export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem {
export class RepoStatusQuickPick { 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 // Sort the status by staged and then filename
const files = status.files; const files = status.files;
files.sort((a, b) => (a.staged ? -1 : 1) - (b.staged ? -1 : 1) || a.fileName.localeCompare(b.fileName)); 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 { Iterables } from '../system';
import { QuickPickOptions, window } from 'vscode'; import { QuickPickOptions, window } from 'vscode';
import { Commands, Keyboard, StashSaveCommandArgs } from '../commands'; import { Commands, Keyboard, StashSaveCommandArgs } from '../commands';
import { GitService, IGitStash } from '../gitService'; import { GitService, GitStash } from '../gitService';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks'; import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks';
export class StashListQuickPick { 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)[]; const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (mode === 'list') { if (mode === 'list') {