diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index bde4da8..7136afc 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -4,7 +4,7 @@ import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } fro import { ActiveEditorCommand, Commands, getCommandUri } from './common'; import { DiffWithCommandArgs } from './diffWith'; import { DiffWithWorkingCommandArgs } from './diffWithWorking'; -import { GitCommit, GitService, GitUri } from '../gitService'; +import { GitCommit, GitCommitType, GitService, GitUri } from '../gitService'; import { Logger } from '../logger'; import { Messages } from '../messages'; @@ -31,7 +31,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { args.line = editor === undefined ? 0 : editor.selection.active.line; } - if (args.commit === undefined || args.commit.type !== 'file' || args.range !== undefined) { + if (args.commit === undefined || args.commit.type !== GitCommitType.File || args.range !== undefined) { const gitUri = await GitUri.fromUri(uri, this.git); try { diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index 0d013f9..d87783a 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -3,7 +3,7 @@ import { Strings } from '../system'; import { commands, TextEditor, Uri, window } from 'vscode'; import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common'; import { GlyphChars } from '../constants'; -import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService'; +import { GitCommit, GitCommitType, GitLog, GitLogCommit, GitService, GitUri } from '../gitService'; import { Logger } from '../logger'; import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks'; import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails'; @@ -81,7 +81,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand { } try { - if (args.commit === undefined || (args.commit.type !== 'branch' && args.commit.type !== 'stash')) { + if (args.commit === undefined || (args.commit.type !== GitCommitType.Branch && args.commit.type !== GitCommitType.Stash)) { if (args.repoLog !== undefined) { args.commit = args.repoLog.commits.get(args.sha!); // If we can't find the commit, kill the repoLog diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index 1cefa00..c0eb677 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -3,7 +3,7 @@ import { Strings } from '../system'; import { TextEditor, Uri, window } from 'vscode'; import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common'; import { GlyphChars } from '../constants'; -import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService'; +import { GitCommit, GitCommitType, GitLog, GitLogCommit, GitService, GitUri } from '../gitService'; import { Logger } from '../logger'; import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; @@ -79,7 +79,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand } try { - if (args.commit === undefined || args.commit.type !== 'file') { + if (args.commit === undefined || args.commit.type !== GitCommitType.File) { if (args.commit !== undefined) { workingFileName = undefined; } diff --git a/src/git/parsers/logParser.ts b/src/git/parsers/logParser.ts index 2d7eb9d..fd41dee 100644 --- a/src/git/parsers/logParser.ts +++ b/src/git/parsers/logParser.ts @@ -113,7 +113,7 @@ export class GitLogParser { break; case 'filename': - if (type === 'branch') { + if (type === GitCommitType.Branch) { next = lines.next(); if (next.done) break; @@ -185,7 +185,7 @@ export class GitLogParser { this._parseFileName(entry); } - if (first && repoPath === undefined && type === 'file' && fileName !== undefined) { + if (first && repoPath === undefined && type === GitCommitType.File && fileName !== undefined) { // Try to get the repoPath from the most recent commit repoPath = Git.normalizePath(fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName!, '')); relativeFileName = Git.normalizePath(path.relative(repoPath, fileName)); @@ -250,7 +250,7 @@ export class GitLogParser { commit.nextSha = commit.sha !== recentCommit.sha ? recentCommit.sha : recentCommit.nextSha; // Only add a filename if this is a file log - if (type === 'file') { + if (type === GitCommitType.File) { recentCommit.previousFileName = commit.originalFileName || commit.fileName; commit.nextFileName = recentCommit.originalFileName || recentCommit.fileName; } diff --git a/src/quickPicks/commitDetails.ts b/src/quickPicks/commitDetails.ts index e8f4f9a..60d3621 100644 --- a/src/quickPicks/commitDetails.ts +++ b/src/quickPicks/commitDetails.ts @@ -4,7 +4,7 @@ import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, DiffWithPreviousCommandArgs, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands'; import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem } from './common'; import { GlyphChars } from '../constants'; -import { getGitStatusOcticon, GitCommit, GitLog, GitLogCommit, GitService, GitStashCommit, GitStatusFile, GitStatusFileStatus, GitUri, IGitCommitInfo, IGitStatusFile, RemoteResource } from '../gitService'; +import { getGitStatusOcticon, GitCommit, GitCommitType, GitLog, GitLogCommit, GitService, GitStashCommit, GitStatusFile, GitStatusFileStatus, GitUri, IGitCommitInfo, IGitStatusFile, RemoteResource } from '../gitService'; import { Keyboard, KeyCommand, KeyNoopCommand, Keys } from '../keyboard'; import { OpenRemotesCommandQuickPickItem } from './remotes'; import * as path from 'path'; @@ -99,7 +99,7 @@ export class CommitDetailsQuickPick { 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'; + const stash = commit.type === GitCommitType.Stash; let index = 0; diff --git a/src/quickPicks/commitFileDetails.ts b/src/quickPicks/commitFileDetails.ts index bb6e839..01eb35a 100644 --- a/src/quickPicks/commitFileDetails.ts +++ b/src/quickPicks/commitFileDetails.ts @@ -4,7 +4,7 @@ import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode'; import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands'; import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './common'; import { GlyphChars } from '../constants'; -import { GitLog, GitLogCommit, GitService, GitUri, RemoteResource } from '../gitService'; +import { GitCommitType, GitLog, GitLogCommit, GitService, GitUri, RemoteResource } from '../gitService'; import { Keyboard, KeyCommand, KeyNoopCommand } from '../keyboard'; import { OpenRemotesCommandQuickPickItem } from './remotes'; import * as path from 'path'; @@ -45,7 +45,7 @@ export class CommitFileDetailsQuickPick { static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, fileLog?: GitLog): Promise { const items: CommandQuickPickItem[] = []; - const stash = commit.type === 'stash'; + const stash = commit.type === GitCommitType.Stash; const workingName = (commit.workingFileName && path.basename(commit.workingFileName)) || path.basename(commit.fileName); diff --git a/src/quickPicks/common.ts b/src/quickPicks/common.ts index 539fe25..d23599d 100644 --- a/src/quickPicks/common.ts +++ b/src/quickPicks/common.ts @@ -4,7 +4,7 @@ import { CancellationTokenSource, commands, Disposable, QuickPickItem, QuickPick import { Commands, openEditor } from '../commands'; import { ExtensionKey, IAdvancedConfig } from '../configuration'; import { GlyphChars } from '../constants'; -import { GitCommit, GitLogCommit, GitStashCommit } from '../gitService'; +import { GitCommit, GitCommitType, GitLogCommit, GitStashCommit } from '../gitService'; import { Keyboard, KeyboardScope, KeyMapping, Keys } from '../keyboard'; // import { Logger } from '../logger'; @@ -178,7 +178,7 @@ export class CommitQuickPickItem implements QuickPickItem { else { this.label = message; this.description = `${Strings.pad('$(git-commit)', 1, 1)} ${commit.shortSha}`; - this.detail = `${GlyphChars.Space} ${commit.author}, ${commit.fromNow()}${(commit.type === 'branch') ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${(commit as GitLogCommit).getDiffStatus()}` : ''}`; + this.detail = `${GlyphChars.Space} ${commit.author}, ${commit.fromNow()}${(commit.type === GitCommitType.Branch) ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${(commit as GitLogCommit).getDiffStatus()}` : ''}`; } } } \ No newline at end of file diff --git a/src/views/commitFileNode.ts b/src/views/commitFileNode.ts index 35542a3..3e9d226 100644 --- a/src/views/commitFileNode.ts +++ b/src/views/commitFileNode.ts @@ -2,7 +2,7 @@ import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import { Commands, DiffWithPreviousCommandArgs } from '../commands'; import { ExplorerNode, ResourceType } from './explorerNode'; -import { CommitFormatter, getGitStatusIcon, GitBranch, GitCommit, GitService, GitUri, ICommitFormatOptions, IGitStatusFile, IStatusFormatOptions, StatusFileFormatter } from '../gitService'; +import { CommitFormatter, getGitStatusIcon, GitBranch, GitCommit, GitCommitType, GitService, GitUri, ICommitFormatOptions, IGitStatusFile, IStatusFormatOptions, StatusFileFormatter } from '../gitService'; import * as path from 'path'; export enum CommitFileNodeDisplayAs { @@ -38,7 +38,7 @@ export class CommitFileNode extends ExplorerNode { } async getTreeItem(): Promise { - if (this.commit.type !== 'file') { + if (this.commit.type !== GitCommitType.File) { const log = await this.git.getLogForFile(this.repoPath, this.status.fileName, this.commit.sha, { maxCount: 2 }); if (log !== undefined) { this.commit = log.commits.get(this.commit.sha) || this.commit;