diff --git a/src/git/models/logCommit.ts b/src/git/models/logCommit.ts index 45e7658..44136af 100644 --- a/src/git/models/logCommit.ts +++ b/src/git/models/logCommit.ts @@ -1,21 +1,15 @@ 'use strict'; import { Uri } from 'vscode'; import { GitCommit, IGitCommitLine } from './commit'; -import { GitStatusFileStatus } from './status'; +import { IGitStatusFile, GitStatusFileStatus } from './status'; import * as path from 'path'; export type GitLogType = 'file' | 'repo'; -export interface IGitLogFileStatusEntry { - status: GitStatusFileStatus; - fileName: string; - originalFileName?: string; -} - export class GitLogCommit extends GitCommit { fileNames: string; - fileStatuses: IGitLogFileStatusEntry[]; + fileStatuses: IGitStatusFile[]; nextSha?: string; nextFileName?: string; parentShas: string[]; @@ -30,7 +24,7 @@ export class GitLogCommit extends GitCommit { date: Date, message: string, status?: GitStatusFileStatus, - fileStatuses?: IGitLogFileStatusEntry[], + fileStatuses?: IGitStatusFile[], lines?: IGitCommitLine[], originalFileName?: string, previousSha?: string, diff --git a/src/git/models/status.ts b/src/git/models/status.ts index d360e58..e526e22 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -1,4 +1,6 @@ 'use strict'; +import { Uri } from 'vscode'; +import * as path from 'path'; export interface IGitStatus { @@ -16,17 +18,27 @@ export interface IGitStatus { export declare type GitStatusFileStatus = '!' | '?' | 'A' | 'C' | 'D' | 'M' | 'R' | 'U'; -export class GitStatusFile { +export interface IGitStatusFile { + status: GitStatusFileStatus; + fileName: string; + originalFileName?: string; +} + +export class GitStatusFile implements IGitStatusFile { originalFileName?: string; - constructor(public repoPath: string, public status: GitStatusFileStatus, public staged: boolean, public fileName: string, originalFileName?: string) { + constructor(public repoPath: string, public status: GitStatusFileStatus, public fileName: string, public staged: boolean, originalFileName?: string) { this.originalFileName = originalFileName; } getIcon() { return getGitStatusIcon(this.status); } + + get Uri(): Uri { + return Uri.file(path.resolve(this.repoPath, this.fileName)); + } } const statusOcticonsMap = { diff --git a/src/git/parsers/logParser.ts b/src/git/parsers/logParser.ts index e0c9db1..814b957 100644 --- a/src/git/parsers/logParser.ts +++ b/src/git/parsers/logParser.ts @@ -1,6 +1,6 @@ 'use strict'; import { Range } from 'vscode'; -import { Git, GitStatusFileStatus, GitLogCommit, GitLogType, IGitAuthor, IGitLog, IGitLogFileStatusEntry } from './../git'; +import { Git, GitStatusFileStatus, GitLogCommit, GitLogType, IGitAuthor, IGitLog, IGitStatusFile } from './../git'; // import { Logger } from '../../logger'; import * as moment from 'moment'; import * as path from 'path'; @@ -18,7 +18,7 @@ interface ILogEntry { fileName?: string; originalFileName?: string; - fileStatuses?: IGitLogFileStatusEntry[]; + fileStatuses?: IGitStatusFile[]; status?: GitStatusFileStatus; @@ -134,7 +134,7 @@ export class GitLogParser { status: line[0] as GitStatusFileStatus, fileName: line.substring(1), originalFileName: undefined as string - } as IGitLogFileStatusEntry; + } as IGitStatusFile; this._parseFileName(status); entry.fileStatuses.push(status); diff --git a/src/git/parsers/statusParser.ts b/src/git/parsers/statusParser.ts index 7c60def..cf13daa 100644 --- a/src/git/parsers/statusParser.ts +++ b/src/git/parsers/statusParser.ts @@ -67,7 +67,7 @@ export class GitStatusParser { else { entry = this._parseFileEntry(rawStatus, fileName); } - status.files.push(new GitStatusFile(repoPath, entry.status, entry.staged, entry.fileName, entry.originalFileName)); + status.files.push(new GitStatusFile(repoPath, entry.status, entry.fileName, entry.staged, entry.originalFileName)); } } } @@ -115,7 +115,7 @@ export class GitStatusParser { } if (entry) { - status.files.push(new GitStatusFile(repoPath, entry.status, entry.staged, entry.fileName, entry.originalFileName)); + status.files.push(new GitStatusFile(repoPath, entry.status, entry.fileName, entry.staged, entry.originalFileName)); } } } diff --git a/src/quickPicks/gitQuickPicks.ts b/src/quickPicks/gitQuickPicks.ts index 4ea8456..70294d4 100644 --- a/src/quickPicks/gitQuickPicks.ts +++ b/src/quickPicks/gitQuickPicks.ts @@ -1,6 +1,6 @@ 'use strict'; import { QuickPickItem, Uri } from 'vscode'; -import { getGitStatusIcon, Git, GitCommit, GitStatusFileStatus, GitService, GitUri, IGitLogFileStatusEntry } from '../gitService'; +import { getGitStatusIcon, Git, GitCommit, GitStatusFileStatus, GitService, GitUri, IGitStatusFile } from '../gitService'; import { OpenFileCommandQuickPickItem } from './quickPicks'; import * as moment from 'moment'; import * as path from 'path'; @@ -26,7 +26,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI shortSha: string; status: GitStatusFileStatus; - constructor(commit: GitCommit, status: IGitLogFileStatusEntry) { + constructor(commit: GitCommit, status: IGitStatusFile) { const icon = getGitStatusIcon(status.status); let directory = Git.normalizePath(path.dirname(status.fileName)); diff --git a/src/quickPicks/repoStatus.ts b/src/quickPicks/repoStatus.ts index a34a05a..234ecd9 100644 --- a/src/quickPicks/repoStatus.ts +++ b/src/quickPicks/repoStatus.ts @@ -9,7 +9,6 @@ import * as path from 'path'; export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem { constructor(status: GitStatusFile, item?: QuickPickItem) { - const uri = Uri.file(path.resolve(status.repoPath, status.fileName)); const icon = status.getIcon(); let directory = Git.normalizePath(path.dirname(status.fileName)); @@ -21,7 +20,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick ? `${directory || ''} \u00a0\u2190\u00a0 ${status.originalFileName}` : directory; - super(uri, item || { + super(status.Uri, item || { label: `${status.staged ? '$(check)' : '\u00a0\u00a0\u00a0'}\u00a0\u00a0${icon}\u00a0\u00a0\u00a0${path.basename(status.fileName)}`, description: description }); @@ -31,8 +30,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem { constructor(statuses: GitStatusFile[], item?: QuickPickItem) { - const repoPath = statuses.length && statuses[0].repoPath; - const uris = statuses.map(_ => Uri.file(path.resolve(repoPath, _.fileName))); + const uris = statuses.map(_ => _.Uri); super(item || { label: `$(file-symlink-file) Open Changed Files`,