diff --git a/src/blameAnnotationFormatter.ts b/src/blameAnnotationFormatter.ts index 745c243..3e23a28 100644 --- a/src/blameAnnotationFormatter.ts +++ b/src/blameAnnotationFormatter.ts @@ -3,7 +3,6 @@ import { IBlameConfig } from './configuration'; import { GitCommit, IGitCommitLine } from './gitProvider'; import * as moment from 'moment'; -export const defaultShaLength = 8; export const defaultAbsoluteDateLength = 10; export const defaultRelativeDateLength = 13; export const defaultAuthorLength = 16; @@ -34,7 +33,7 @@ export enum BlameAnnotationFormat { export class BlameAnnotationFormatter { static getAnnotation(config: IBlameConfig, commit: GitCommit, format: BlameAnnotationFormat) { - const sha = commit.sha.substring(0, defaultShaLength); + const sha = commit.shortSha; let message = this.getMessage(config, commit, format === BlameAnnotationFormat.Unconstrained ? 0 : defaultMessageLength); if (format === BlameAnnotationFormat.Unconstrained) { @@ -70,7 +69,7 @@ export class BlameAnnotationFormatter { return `\`${'0'.repeat(8)}\`   __Uncommitted changes__`; } - return `\`${commit.sha}\`   __${commit.author}__, ${moment(commit.date).fromNow()} _(${moment(commit.date).format(config.annotation.dateFormat || 'MMMM Do, YYYY h:MMa')})_ \n\n${message}`; + return `\`${commit.shortSha}\`   __${commit.author}__, ${moment(commit.date).fromNow()} _(${moment(commit.date).format(config.annotation.dateFormat || 'MMMM Do, YYYY h:MMa')})_ \n\n${message}`; } static getAuthorAndDate(config: IBlameConfig, commit: GitCommit, format: string, force: boolean = false) { diff --git a/src/blameAnnotationProvider.ts b/src/blameAnnotationProvider.ts index e033729..70ac41f 100644 --- a/src/blameAnnotationProvider.ts +++ b/src/blameAnnotationProvider.ts @@ -1,7 +1,7 @@ 'use strict'; import { Iterables } from './system'; import { DecorationInstanceRenderOptions, DecorationOptions, Disposable, ExtensionContext, Range, TextDocument, TextEditor, TextEditorSelectionChangeEvent, window, workspace } from 'vscode'; -import { BlameAnnotationFormat, BlameAnnotationFormatter, cssIndent, defaultShaLength, defaultAuthorLength } from './blameAnnotationFormatter'; +import { BlameAnnotationFormat, BlameAnnotationFormatter, cssIndent, defaultAuthorLength } from './blameAnnotationFormatter'; import { BlameDecorations } from './blameAnnotationController'; import { TextDocumentComparer } from './comparers'; import { BlameAnnotationStyle, IBlameConfig } from './configuration'; @@ -167,7 +167,7 @@ export class BlameAnnotationProvider extends Disposable { if (!isEmptyOrWhitespace) { switch (++count) { case 0: - gutter = commit.sha.substring(0, defaultShaLength); + gutter = commit.shortSha; break; case 1: gutter = `${cssIndent} ${BlameAnnotationFormatter.getAuthor(this._config, commit, defaultAuthorLength, true)}`; diff --git a/src/commands/diffLineWithPrevious.ts b/src/commands/diffLineWithPrevious.ts index 71766db..f866552 100644 --- a/src/commands/diffLineWithPrevious.ts +++ b/src/commands/diffLineWithPrevious.ts @@ -59,7 +59,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand { this.git.getVersionedFile(gitUri.fsPath, gitUri.repoPath, gitUri.sha), this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha) ]); - await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.sha}) ↔ ${path.basename(gitUri.fsPath)} (${gitUri.sha})`); + await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(gitUri.fsPath)} (${gitUri.shortSha})`); // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' }); } diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index 45dfa27..49f10dd 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -63,7 +63,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand { this.git.getVersionedFile(commit.nextUri.fsPath, commit.repoPath, commit.nextSha), this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha) ]); - await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.sha}) ↔ ${path.basename(commit.nextUri.fsPath)} (${commit.nextSha})`); + await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(commit.nextUri.fsPath)} (${commit.nextShortSha})`); return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' }); } catch (ex) { diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index 0d027f4..802255c 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -55,7 +55,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { } if (!commit.previousSha) { - return window.showInformationMessage(`Commit ${commit.sha} (${commit.author}, ${moment(commit.date).fromNow()}) has no previous commit`); + return window.showInformationMessage(`Commit ${commit.shortSha} (${commit.author}, ${moment(commit.date).fromNow()}) has no previous commit`); } try { @@ -63,7 +63,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha), this.git.getVersionedFile(commit.previousUri.fsPath, commit.repoPath, commit.previousSha) ]); - await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.previousUri.fsPath)} (${commit.previousSha}) ↔ ${path.basename(commit.uri.fsPath)} (${commit.sha})`); + await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.previousUri.fsPath)} (${commit.previousShortSha}) ↔ ${path.basename(commit.uri.fsPath)} (${commit.shortSha})`); // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' }); } diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index cd22f3f..c371cb2 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -42,7 +42,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { try { const compare = await this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha); - await commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), gitUri.fileUri(), `${path.basename(commit.uri.fsPath)} (${commit.sha}) ↔ ${path.basename(gitUri.fsPath)}`); + await commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), gitUri.fileUri(), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(gitUri.fsPath)}`); return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' }); } catch (ex) { diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index 97c64dd..bfacb59 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -70,7 +70,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCommand { // Create a command to get back to where we are right now new CommandQuickPickItem({ label: `go back \u21A9`, - description: `\u00a0 \u2014 \u00a0\u00a0 to details of \u00a0$(git-commit) ${pick.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 to details of \u00a0$(git-commit) ${pick.shortSha}` }, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), sha, commit, goBackCommand])); } catch (ex) { diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index 282d96f..a1e8212 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -57,11 +57,13 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCommand { // TODO: Leave this at undefined until findMostRecentCommitForFile actually works const workingFileName = !workingCommit ? commit.fileName : undefined; + const shortSha = sha.substring(0, 8); + if (!goBackCommand) { // Create a command to get back to the commit details goBackCommand = new CommandQuickPickItem({ label: `go back \u21A9`, - description: `\u00a0 \u2014 \u00a0\u00a0 to details of \u00a0$(git-commit) ${sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 to details of \u00a0$(git-commit) ${shortSha}` }, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), sha, commit]); } @@ -69,7 +71,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCommand { // Create a command to get back to where we are right now new CommandQuickPickItem({ label: `go back \u21A9`, - description: `\u00a0 \u2014 \u00a0\u00a0 to details of \u00a0$(file-text) ${path.basename(commit.fileName)} in \u00a0$(git-commit) ${sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 to details of \u00a0$(file-text) ${path.basename(commit.fileName)} in \u00a0$(git-commit) ${shortSha}` }, Commands.ShowQuickCommitFileDetails, [new GitUri(commit.uri, commit), sha, commit, goBackCommand, options]), { showFileHistory: options.showFileHistory }); diff --git a/src/git/enrichers/blameParserEnricher.ts b/src/git/enrichers/blameParserEnricher.ts index 09853c7..c06852e 100644 --- a/src/git/enrichers/blameParserEnricher.ts +++ b/src/git/enrichers/blameParserEnricher.ts @@ -5,6 +5,7 @@ import * as path from 'path'; interface IBlameEntry { sha: string; + line: number; originalLine: number; lineCount: number; @@ -53,7 +54,7 @@ export class GitBlameParserEnricher implements IGitEnricher { if (!entry) { entry = { - sha: lineParts[0].substring(0, 8), + sha: lineParts[0], originalLine: parseInt(lineParts[1], 10) - 1, line: parseInt(lineParts[2], 10) - 1, lineCount: parseInt(lineParts[3], 10) @@ -102,7 +103,7 @@ export class GitBlameParserEnricher implements IGitEnricher { break; case 'previous': - entry.previousSha = lineParts[1].substring(0, 8); + entry.previousSha = lineParts[1]; entry.previousFileName = lineParts.slice(2).join(' '); break; diff --git a/src/git/enrichers/logParserEnricher.ts b/src/git/enrichers/logParserEnricher.ts index 0d0d781..15021b4 100644 --- a/src/git/enrichers/logParserEnricher.ts +++ b/src/git/enrichers/logParserEnricher.ts @@ -21,6 +21,8 @@ interface ILogEntry { summary?: string; } +const shaRegex = /^[a-f0-9]{40}$/; + export class GitLogParserEnricher implements IGitEnricher { private _parseEntries(data: string, isRepoPath: boolean): ILogEntry[] { @@ -40,9 +42,9 @@ export class GitLogParserEnricher implements IGitEnricher { } if (!entry) { - if (!/^[a-f0-9]{40}$/.test(lineParts[0])) continue; + if (!shaRegex.test(lineParts[0])) continue; entry = { - sha: lineParts[0].substring(0, 8) + sha: lineParts[0] }; continue; diff --git a/src/git/git.ts b/src/git/git.ts index f423c38..c6283fa 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -115,9 +115,10 @@ export default class Git { static async getVersionedFile(fileName: string, repoPath: string, sha: string) { const data = await Git.getVersionedFileText(fileName, repoPath, sha); + const shortSha = sha.substring(0, 8); const ext = path.extname(fileName); return new Promise((resolve, reject) => { - tmp.file({ prefix: `${path.basename(fileName, ext)}-${sha}__`, postfix: ext }, + tmp.file({ prefix: `${path.basename(fileName, ext)}-${shortSha}__`, postfix: ext }, (err, destination, fd, cleanupCallback) => { if (err) { reject(err); diff --git a/src/git/gitEnrichment.ts b/src/git/gitEnrichment.ts index f0eac45..d4f0e16 100644 --- a/src/git/gitEnrichment.ts +++ b/src/git/gitEnrichment.ts @@ -80,6 +80,10 @@ export class GitCommit implements IGitCommit { this.previousFileName = previousFileName; } + get shortSha() { + return this.sha.substring(0, 8); + } + get isUncommitted(): boolean { if (this._isUncommitted === undefined) { this._isUncommitted = Git.isUncommitted(this.sha); @@ -87,6 +91,10 @@ export class GitCommit implements IGitCommit { return this._isUncommitted; } + get previousShortSha() { + return this.previousSha && this.previousSha.substring(0, 8); + } + get previousUri(): Uri { return this.previousFileName ? Uri.file(path.join(this.repoPath, this.previousFileName)) : this.uri; } @@ -138,6 +146,10 @@ export class GitLogCommit extends GitCommit { } } + get nextShortSha() { + return this.nextSha && this.nextSha.substring(0, 8); + } + get nextUri(): Uri { return this.nextFileName ? Uri.file(path.join(this.repoPath, this.nextFileName)) : this.uri; } diff --git a/src/git/gitUri.ts b/src/git/gitUri.ts index d13008f..3b91410 100644 --- a/src/git/gitUri.ts +++ b/src/git/gitUri.ts @@ -49,6 +49,10 @@ export class GitUri extends Uri { } } + get shortSha() { + return this.sha && this.sha.substring(0, 8); + } + fileUri() { return Uri.file(this.sha ? this.path : this.fsPath); } diff --git a/src/gitCodeLensProvider.ts b/src/gitCodeLensProvider.ts index 78c760b..7df384c 100644 --- a/src/gitCodeLensProvider.ts +++ b/src/gitCodeLensProvider.ts @@ -262,7 +262,7 @@ export default class GitCodeLensProvider implements CodeLensProvider { const recentCommit = Iterables.first(blame.commits.values()); title = `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`; if (this._config.advanced.debug && this._config.advanced.output.level === OutputLevel.Verbose) { - title += ` [Commit (${recentCommit.sha}), Symbol (${SymbolKind[lens.symbolKind]}), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1})]`; + title += ` [Commit (${recentCommit.shortSha}), Symbol (${SymbolKind[lens.symbolKind]}), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1})]`; } switch (this._config.codeLens.recentChange.command) { diff --git a/src/gitContentProvider.ts b/src/gitContentProvider.ts index fe894b6..55c6cc6 100644 --- a/src/gitContentProvider.ts +++ b/src/gitContentProvider.ts @@ -23,7 +23,7 @@ export class GitContentProvider implements TextDocumentContentProvider { } catch (ex) { Logger.error('[GitLens.GitContentProvider]', 'getVersionedFileText', ex); - await window.showErrorMessage(`Unable to show Git revision ${data.sha} of '${path.relative(data.repoPath, fileName)}'`); + await window.showErrorMessage(`Unable to show Git revision ${data.sha.substring(0, 8)} of '${path.relative(data.repoPath, fileName)}'`); return undefined; } } diff --git a/src/gitRevisionCodeLensProvider.ts b/src/gitRevisionCodeLensProvider.ts index 8e577bd..7671f8c 100644 --- a/src/gitRevisionCodeLensProvider.ts +++ b/src/gitRevisionCodeLensProvider.ts @@ -54,7 +54,7 @@ export class GitRevisionCodeLensProvider implements CodeLensProvider { _resolveDiffWithWorkingTreeCodeLens(lens: GitDiffWithWorkingCodeLens, token: CancellationToken): Thenable { lens.command = { - title: `Compare ${lens.commit.sha} with Working Tree`, + title: `Compare ${lens.commit.shortSha} with Working Tree`, command: Commands.DiffWithWorking, arguments: [ Uri.file(lens.fileName), @@ -67,7 +67,7 @@ export class GitRevisionCodeLensProvider implements CodeLensProvider { _resolveGitDiffWithPreviousCodeLens(lens: GitDiffWithPreviousCodeLens, token: CancellationToken): Thenable { lens.command = { - title: `Compare ${lens.commit.sha} with Previous ${lens.commit.previousSha}`, + title: `Compare ${lens.commit.shortSha} with Previous ${lens.commit.previousShortSha}`, command: Commands.DiffWithPrevious, arguments: [ Uri.file(lens.fileName), diff --git a/src/quickPicks/commitDetails.ts b/src/quickPicks/commitDetails.ts index bdb4c54..7a04da2 100644 --- a/src/quickPicks/commitDetails.ts +++ b/src/quickPicks/commitDetails.ts @@ -14,8 +14,8 @@ export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPi const uris = commit.fileStatuses.map(_ => GitProvider.toGitContentUri(commit.sha, _.fileName, repoPath, commit.originalFileName)); super(uris, item || { label: `$(file-symlink-file) Open Changed Files`, - description: `\u00a0 \u2014 \u00a0\u00a0 in \u00a0$(git-commit) ${commit.sha}` - //detail: `Opens all of the changed files in $(git-commit) ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 in \u00a0$(git-commit) ${commit.shortSha}` + //detail: `Opens all of the changed files in $(git-commit) ${commit.shortSha}` }); } } @@ -42,7 +42,7 @@ export class CommitDetailsQuickPick { items.splice(index++, 0, new CommandQuickPickItem({ label: `$(clippy) Copy Commit Sha to Clipboard`, - description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.shortSha}` }, Commands.CopyShaToClipboard, [uri, commit.sha])); items.splice(index++, 0, new CommandQuickPickItem({ @@ -52,12 +52,12 @@ export class CommitDetailsQuickPick { items.splice(index++, 0, new CommandQuickPickItem({ label: `$(git-compare) Directory Compare with Previous Commit`, - description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousSha || `${commit.sha}^`} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousShortSha || `${commit.shortSha}^`} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.shortSha}` }, Commands.DiffDirectory, [commit.uri, commit.previousSha || `${commit.sha}^`, commit.sha])); items.splice(index++, 0, new CommandQuickPickItem({ label: `$(git-compare) Directory Compare with Working Tree`, - description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-directory) Working Tree` + description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha} \u00a0 $(git-compare) \u00a0 $(file-directory) Working Tree` }, Commands.DiffDirectory, [uri, commit.sha])); items.splice(index++, 0, new CommandQuickPickItem({ @@ -77,7 +77,7 @@ export class CommitDetailsQuickPick { const pick = await window.showQuickPick(items, { matchOnDescription: true, matchOnDetail: true, - placeHolder: `${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, + placeHolder: `${commit.shortSha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, ignoreFocusOut: getQuickPickIgnoreFocusOut(), onDidSelectItem: (item: QuickPickItem) => { Keyboard.instance.setKeyCommand('right', item); diff --git a/src/quickPicks/commitFileDetails.ts b/src/quickPicks/commitFileDetails.ts index 9e44924..583dea2 100644 --- a/src/quickPicks/commitFileDetails.ts +++ b/src/quickPicks/commitFileDetails.ts @@ -13,7 +13,7 @@ export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPick const uri = GitProvider.toGitContentUri(commit); super(uri, item || { label: `$(file-symlink-file) Open File`, - description: `\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)} in \u00a0$(git-commit) ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)} in \u00a0$(git-commit) ${commit.shortSha}` }); } } @@ -48,25 +48,25 @@ export class CommitFileDetailsQuickPick { if (!options.showFileHistory) { items.push(new CommandQuickPickItem({ label: `$(git-commit) Show Commit Details`, - description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}` }, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), commit.sha, commit, currentCommand])); } if (commit.previousSha) { items.push(new CommandQuickPickItem({ label: `$(git-compare) Compare with Previous Commit`, - description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousShortSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.shortSha}` }, Commands.DiffWithPrevious, [commit.uri, commit])); } items.push(new CommandQuickPickItem({ label: `$(git-compare) Compare with Working Tree`, - description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingName}` + description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingName}` }, Commands.DiffWithWorking, [uri, commit])); items.push(new CommandQuickPickItem({ label: `$(clippy) Copy Commit Sha to Clipboard`, - description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.shortSha}` }, Commands.CopyShaToClipboard, [uri, commit.sha])); items.push(new CommandQuickPickItem({ @@ -86,7 +86,7 @@ export class CommitFileDetailsQuickPick { items.push(new CommandQuickPickItem({ label: `$(history) Show ${workingFileName && options.showFileHistory ? 'Previous ' : ''}File History`, - description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(commit.fileName)} \u00a0\u2022\u00a0 starting from \u00a0$(git-commit) ${commit.sha}` + description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(commit.fileName)} \u00a0\u2022\u00a0 starting from \u00a0$(git-commit) ${commit.shortSha}` }, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand])); if (goBackCommand) { @@ -97,7 +97,7 @@ export class CommitFileDetailsQuickPick { const pick = await window.showQuickPick(items, { matchOnDescription: true, - placeHolder: `${commit.getFormattedPath()} \u2022 ${isUncommitted ? 'Uncommitted \u21E8 ' : '' }${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, + placeHolder: `${commit.getFormattedPath()} \u2022 ${isUncommitted ? 'Uncommitted \u21E8 ' : '' }${commit.shortSha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, ignoreFocusOut: getQuickPickIgnoreFocusOut(), onDidSelectItem: (item: QuickPickItem) => { Keyboard.instance.setKeyCommand('right', item); diff --git a/src/quickPicks/fileHistory.ts b/src/quickPicks/fileHistory.ts index 996cd17..6a8f798 100644 --- a/src/quickPicks/fileHistory.ts +++ b/src/quickPicks/fileHistory.ts @@ -48,7 +48,7 @@ export class FileHistoryQuickPick { const pick = await window.showQuickPick(items, { matchOnDescription: true, matchOnDetail: true, - placeHolder: `${commit.getFormattedPath()}${sha ? ` \u00a0\u2022\u00a0 ${sha}` : ''}`, + placeHolder: `${commit.getFormattedPath()}${sha ? ` \u00a0\u2022\u00a0 ${sha.substring(0, 8)}` : ''}`, ignoreFocusOut: getQuickPickIgnoreFocusOut(), onDidSelectItem: (item: QuickPickItem) => { Keyboard.instance.setKeyCommand('right', item); diff --git a/src/quickPicks/gitQuickPicks.ts b/src/quickPicks/gitQuickPicks.ts index 78c71c9..521b843 100644 --- a/src/quickPicks/gitQuickPicks.ts +++ b/src/quickPicks/gitQuickPicks.ts @@ -13,7 +13,7 @@ export class CommitQuickPickItem implements QuickPickItem { constructor(public commit: GitCommit, descriptionSuffix: string = '') { this.label = `${commit.author}, ${moment(commit.date).fromNow()}`; - this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}${descriptionSuffix}`; + this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}${descriptionSuffix}`; this.detail = commit.message; } } @@ -23,6 +23,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI fileName: string; gitUri: GitUri; sha: string; + shortSha: string; status: GitFileStatus; constructor(commit: GitCommit, fileName: string, status: GitFileStatus) { @@ -41,6 +42,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI this.fileName = fileName; this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, fileName))); this.sha = commit.sha; + this.shortSha = commit.shortSha; this.status = status; } } \ No newline at end of file