diff --git a/src/annotations/blameAnnotationProvider.ts b/src/annotations/blameAnnotationProvider.ts index 8e02c47..ef77364 100644 --- a/src/annotations/blameAnnotationProvider.ts +++ b/src/annotations/blameAnnotationProvider.ts @@ -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; + protected _blame: Promise; 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 { + protected async getBlame(requiresWhitespaceHack: boolean): Promise { let whitespacePromise: Promise | 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]); } diff --git a/src/commands/showQuickBranchHistory.ts b/src/commands/showQuickBranchHistory.ts index ef9a7e0..7a84dc4 100644 --- a/src/commands/showQuickBranchHistory.ts +++ b/src/commands/showQuickBranchHistory.ts @@ -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; diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index 269633a..14d4681 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -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; } diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index 11dd8f3..879eec5 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -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; } diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index 4a6d84b..95d91a0 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -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; diff --git a/src/currentLineController.ts b/src/currentLineController.ts index a7b57f5..9b4b2a1 100644 --- a/src/currentLineController.ts +++ b/src/currentLineController.ts @@ -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; diff --git a/src/git/formatters/commit.ts b/src/git/formatters/commit.ts index 3a49ed0..ffb837c 100644 --- a/src/git/formatters/commit.ts +++ b/src/git/formatters/commit.ts @@ -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}\`   __${commit.author}__, ${moment(commit.date).fromNow()}   _(${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\`   \u2014   \`${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()} diff --git a/src/git/models/blame.ts b/src/git/models/blame.ts index ae07031..2634298 100644 --- a/src/git/models/blame.ts +++ b/src/git/models/blame.ts @@ -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; + authors: Map; commits: Map; - 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[]; } \ No newline at end of file diff --git a/src/git/models/commit.ts b/src/git/models/commit.ts index 5b85c3c..5649ac9 100644 --- a/src/git/models/commit.ts +++ b/src/git/models/commit.ts @@ -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 diff --git a/src/git/models/diff.ts b/src/git/models/diff.ts index 51c1d3e..392b259 100644 --- a/src/git/models/diff.ts +++ b/src/git/models/diff.ts @@ -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; } \ No newline at end of file diff --git a/src/git/models/log.ts b/src/git/models/log.ts index e94e96c..3d5b873 100644 --- a/src/git/models/log.ts +++ b/src/git/models/log.ts @@ -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; + authors: Map; commits: Map; sha: string | undefined; diff --git a/src/git/models/logCommit.ts b/src/git/models/logCommit.ts index 02c6850..3d1700f 100644 --- a/src/git/models/logCommit.ts +++ b/src/git/models/logCommit.ts @@ -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 diff --git a/src/git/models/stash.ts b/src/git/models/stash.ts index 297a498..42cf645 100644 --- a/src/git/models/stash.ts +++ b/src/git/models/stash.ts @@ -1,7 +1,7 @@ 'use strict'; import { GitStashCommit } from './stashCommit'; -export interface IGitStash { +export interface GitStash { repoPath: string; commits: Map; } \ No newline at end of file diff --git a/src/git/models/stashCommit.ts b/src/git/models/stashCommit.ts index 5a47afa..c19c835 100644 --- a/src/git/models/stashCommit.ts +++ b/src/git/models/stashCommit.ts @@ -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 diff --git a/src/git/models/status.ts b/src/git/models/status.ts index e526e22..3f3f254 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -2,7 +2,7 @@ import { Uri } from 'vscode'; import * as path from 'path'; -export interface IGitStatus { +export interface GitStatus { branch: string; repoPath: string; diff --git a/src/git/parsers/blameParser.ts b/src/git/parsers/blameParser.ts index 7f966d5..0196c6a 100644 --- a/src/git/parsers/blameParser.ts +++ b/src/git/parsers/blameParser.ts @@ -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 = new Map(); + const authors: Map = new Map(); const commits: Map = 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 = new Map(); + const sortedAuthors: Map = 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; } } \ No newline at end of file diff --git a/src/git/parsers/diffParser.ts b/src/git/parsers/diffParser.ts index 569aac6..444aa3e 100644 --- a/src/git/parsers/diffParser.ts +++ b/src/git/parsers/diffParser.ts @@ -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; } } \ No newline at end of file diff --git a/src/git/parsers/logParser.ts b/src/git/parsers/logParser.ts index 3bc13a0..695e66a 100644 --- a/src/git/parsers/logParser.ts +++ b/src/git/parsers/logParser.ts @@ -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 = new Map(); + const authors: Map = new Map(); const commits: Map = new Map(); let relativeFileName: string; @@ -245,7 +245,7 @@ export class GitLogParser { author.lineCount += c.lines.length; }); - const sortedAuthors: Map = new Map(); + const sortedAuthors: Map = 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 }) { diff --git a/src/git/parsers/stashParser.ts b/src/git/parsers/stashParser.ts index ba355b0..41baa68 100644 --- a/src/git/parsers/stashParser.ts +++ b/src/git/parsers/stashParser.ts @@ -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 }) { diff --git a/src/git/parsers/statusParser.ts b/src/git/parsers/statusParser.ts index 3580b79..50b732d 100644 --- a/src/git/parsers/statusParser.ts +++ b/src/git/parsers/statusParser.ts @@ -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; } } \ No newline at end of file diff --git a/src/gitCodeLensProvider.ts b/src/gitCodeLensProvider.ts index aa70cbc..adbe083 100644 --- a/src/gitCodeLensProvider.ts +++ b/src/gitCodeLensProvider.ts @@ -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 ]); - 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(title: string, lens: T, blame: IGitBlameLines): T { + _applyBlameAnnotateCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyShowBlameHistoryCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyShowFileHistoryCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyDiffWithPreviousCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyShowQuickCommitDetailsCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyShowQuickCommitFileDetailsCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyShowQuickFileHistoryCommand(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(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T { + _applyShowQuickBranchHistoryCommand(title: string, lens: T, blame: GitBlameLines, commit?: GitCommit): T { lens.command = { title: title, command: CodeLensCommand.ShowQuickCurrentBranchHistory, diff --git a/src/gitService.ts b/src/gitService.ts index 123e0e1..3ebd507 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -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 = new Map(); + private cache: Map = new Map(); constructor(public key: string) { } @@ -34,23 +34,23 @@ class GitCacheEntry { return Iterables.every(this.cache.values(), _ => _.errorMessage !== undefined); } - get(key: string): T | undefined { + get(key: string): T | undefined { return this.cache.get(key) as T; } - set(key: string, value: T) { + set(key: string, value: T) { this.cache.set(key, value); } } -interface ICachedItem { +interface CachedItem { item: Promise; errorMessage?: string; } -interface ICachedBlame extends ICachedItem { } -interface ICachedDiff extends ICachedItem { } -interface ICachedLog extends ICachedItem { } +interface CachedBlame extends CachedItem { } +interface CachedDiff extends CachedItem { } +interface CachedLog extends CachedItem { } enum RemoveCacheReason { DocumentClosed, @@ -89,7 +89,7 @@ export class GitService extends Disposable { private _fsWatcher: FileSystemWatcher | undefined; private _gitignore: Promise; - static EmptyPromise: Promise = Promise.resolve(undefined); + static EmptyPromise: Promise = 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 { + async getBlameForFile(uri: GitUri): Promise { 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(key); + const cachedBlame = entry.get(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(key, { + entry.set(key, { item: promise - } as ICachedBlame); + } as CachedBlame); } return promise; } - private async _getBlameForFile(uri: GitUri, entry: GitCacheEntry | undefined, key: string): Promise { + private async _getBlameForFile(uri: GitUri, entry: GitCacheEntry | undefined, key: string): Promise { 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(key, { + entry.set(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 { + async getBlameForLine(uri: GitUri, line: number): Promise { 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 { + async getBlameForRange(uri: GitUri, range: Range): Promise { 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 = new Set(); lines.forEach(l => shas.add(l.sha)); - const authors: Map = new Map(); + const authors: Map = new Map(); const commits: Map = 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 = new Map(); + const sortedAuthors: Map = 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 { @@ -574,7 +574,7 @@ export class GitService extends Disposable { return entry && entry.uri; } - async getDiffForFile(uri: GitUri, sha1?: string, sha2?: string): Promise { + async getDiffForFile(uri: GitUri, sha1?: string, sha2?: string): Promise { 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(key); + const cachedDiff = entry.get(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(key, { + entry.set(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 { + private async _getDiffForFile(repoPath: string | undefined, fileName: string, sha1: string | undefined, sha2: string | undefined, entry: GitCacheEntry | undefined, key: string): Promise { 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(key, { + entry.set(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 { + async getLogForRepo(repoPath: string, sha?: string, maxCount?: number, reverse: boolean = false): Promise { 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 { + async getLogForRepoSearch(repoPath: string, search: string, searchBy: GitRepoSearchBy, maxCount?: number): Promise { 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 { + async getLogForFile(repoPath: string | undefined, fileName: string, sha?: string, maxCount?: number, range?: Range, reverse: boolean = false): Promise { 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(key); + const cachedLog = entry.get(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('log'); + const cachedLog = entry.get('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(key, { + entry.set(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 { + 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 { 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(key, { + entry.set(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 { + async getStashList(repoPath: string): Promise { 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 { + async getStatusForRepo(repoPath: string): Promise { Logger.log(`getStatusForRepo('${repoPath}')`); const porcelainVersion = Git.validateVersion(2, 11) ? 2 : 1; diff --git a/src/quickPicks/branchHistory.ts b/src/quickPicks/branchHistory.ts index 8933acc..687e389 100644 --- a/src/quickPicks/branchHistory.ts +++ b/src/quickPicks/branchHistory.ts @@ -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 { + static async show(git: GitService, log: GitLog, uri: GitUri | undefined, branch: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise { const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[]; const currentCommand = new CommandQuickPickItem({ diff --git a/src/quickPicks/commitDetails.ts b/src/quickPicks/commitDetails.ts index ed8f55a..d099cac 100644 --- a/src/quickPicks/commitDetails.ts +++ b/src/quickPicks/commitDetails.ts @@ -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 { + static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, repoLog?: GitLog): Promise { const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs)); const stash = commit.type === 'stash'; diff --git a/src/quickPicks/commitFileDetails.ts b/src/quickPicks/commitFileDetails.ts index 03454f6..6e7cc15 100644 --- a/src/quickPicks/commitFileDetails.ts +++ b/src/quickPicks/commitFileDetails.ts @@ -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 { + static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, fileLog?: GitLog): Promise { const items: CommandQuickPickItem[] = []; const stash = commit.type === 'stash'; diff --git a/src/quickPicks/commits.ts b/src/quickPicks/commits.ts index 02a280b..b1593dc 100644 --- a/src/quickPicks/commits.ts +++ b/src/quickPicks/commits.ts @@ -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 { + static async show(git: GitService, log: GitLog, placeHolder: string, goBackCommand?: CommandQuickPickItem): Promise { const items = ((log && Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; if (goBackCommand) { diff --git a/src/quickPicks/fileHistory.ts b/src/quickPicks/fileHistory.ts index 49e68e5..0d3a582 100644 --- a/src/quickPicks/fileHistory.ts +++ b/src/quickPicks/fileHistory.ts @@ -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 { + static async show(git: GitService, log: GitLog, uri: GitUri, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise { const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[]; let previousPageCommand: CommandQuickPickItem | undefined = undefined; diff --git a/src/quickPicks/repoStatus.ts b/src/quickPicks/repoStatus.ts index 2b55551..f1deeae 100644 --- a/src/quickPicks/repoStatus.ts +++ b/src/quickPicks/repoStatus.ts @@ -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 { + static async show(status: GitStatus, goBackCommand?: CommandQuickPickItem): Promise { // 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)); diff --git a/src/quickPicks/stashList.ts b/src/quickPicks/stashList.ts index 6f95ecd..df301ff 100644 --- a/src/quickPicks/stashList.ts +++ b/src/quickPicks/stashList.ts @@ -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 { + static async show(git: GitService, stash: GitStash, mode: 'list' | 'apply', goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem): Promise { const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; if (mode === 'list') {