Switches everything to use full shas

This commit is contained in:
Eric Amodio
2017-03-10 22:26:48 -05:00
parent df838e883a
commit 762fa545c7
20 changed files with 60 additions and 37 deletions

View File

@@ -3,7 +3,6 @@ import { IBlameConfig } from './configuration';
import { GitCommit, IGitCommitLine } from './gitProvider'; import { GitCommit, IGitCommitLine } from './gitProvider';
import * as moment from 'moment'; import * as moment from 'moment';
export const defaultShaLength = 8;
export const defaultAbsoluteDateLength = 10; export const defaultAbsoluteDateLength = 10;
export const defaultRelativeDateLength = 13; export const defaultRelativeDateLength = 13;
export const defaultAuthorLength = 16; export const defaultAuthorLength = 16;
@@ -34,7 +33,7 @@ export enum BlameAnnotationFormat {
export class BlameAnnotationFormatter { export class BlameAnnotationFormatter {
static getAnnotation(config: IBlameConfig, commit: GitCommit, format: BlameAnnotationFormat) { 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); let message = this.getMessage(config, commit, format === BlameAnnotationFormat.Unconstrained ? 0 : defaultMessageLength);
if (format === BlameAnnotationFormat.Unconstrained) { if (format === BlameAnnotationFormat.Unconstrained) {
@@ -70,7 +69,7 @@ export class BlameAnnotationFormatter {
return `\`${'0'.repeat(8)}\`   __Uncommitted changes__`; 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) { static getAuthorAndDate(config: IBlameConfig, commit: GitCommit, format: string, force: boolean = false) {

View File

@@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { Iterables } from './system'; import { Iterables } from './system';
import { DecorationInstanceRenderOptions, DecorationOptions, Disposable, ExtensionContext, Range, TextDocument, TextEditor, TextEditorSelectionChangeEvent, window, workspace } from 'vscode'; 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 { BlameDecorations } from './blameAnnotationController';
import { TextDocumentComparer } from './comparers'; import { TextDocumentComparer } from './comparers';
import { BlameAnnotationStyle, IBlameConfig } from './configuration'; import { BlameAnnotationStyle, IBlameConfig } from './configuration';
@@ -167,7 +167,7 @@ export class BlameAnnotationProvider extends Disposable {
if (!isEmptyOrWhitespace) { if (!isEmptyOrWhitespace) {
switch (++count) { switch (++count) {
case 0: case 0:
gutter = commit.sha.substring(0, defaultShaLength); gutter = commit.shortSha;
break; break;
case 1: case 1:
gutter = `${cssIndent} ${BlameAnnotationFormatter.getAuthor(this._config, commit, defaultAuthorLength, true)}`; gutter = `${cssIndent} ${BlameAnnotationFormatter.getAuthor(this._config, commit, defaultAuthorLength, true)}`;

View File

@@ -59,7 +59,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
this.git.getVersionedFile(gitUri.fsPath, gitUri.repoPath, gitUri.sha), this.git.getVersionedFile(gitUri.fsPath, gitUri.repoPath, gitUri.sha),
this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.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 // TODO: Figure out how to focus the left pane
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' }); return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
} }

View File

@@ -63,7 +63,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
this.git.getVersionedFile(commit.nextUri.fsPath, commit.repoPath, commit.nextSha), this.git.getVersionedFile(commit.nextUri.fsPath, commit.repoPath, commit.nextSha),
this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.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(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' }); return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
} }
catch (ex) { catch (ex) {

View File

@@ -55,7 +55,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
} }
if (!commit.previousSha) { 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 { try {
@@ -63,7 +63,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha), this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha),
this.git.getVersionedFile(commit.previousUri.fsPath, commit.repoPath, commit.previousSha) 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 // TODO: Figure out how to focus the left pane
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' }); return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
} }

View File

@@ -42,7 +42,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
try { try {
const compare = await this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha); 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' }); return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
} }
catch (ex) { catch (ex) {

View File

@@ -70,7 +70,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
// Create a command to get back to where we are right now // Create a command to get back to where we are right now
new CommandQuickPickItem({ new CommandQuickPickItem({
label: `go back \u21A9`, 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])); }, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), sha, commit, goBackCommand]));
} }
catch (ex) { catch (ex) {

View File

@@ -57,11 +57,13 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCommand {
// TODO: Leave this at undefined until findMostRecentCommitForFile actually works // TODO: Leave this at undefined until findMostRecentCommitForFile actually works
const workingFileName = !workingCommit ? commit.fileName : undefined; const workingFileName = !workingCommit ? commit.fileName : undefined;
const shortSha = sha.substring(0, 8);
if (!goBackCommand) { if (!goBackCommand) {
// Create a command to get back to the commit details // Create a command to get back to the commit details
goBackCommand = new CommandQuickPickItem({ goBackCommand = new CommandQuickPickItem({
label: `go back \u21A9`, 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]); }, 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 // Create a command to get back to where we are right now
new CommandQuickPickItem({ new CommandQuickPickItem({
label: `go back \u21A9`, 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]), }, Commands.ShowQuickCommitFileDetails, [new GitUri(commit.uri, commit), sha, commit, goBackCommand, options]),
{ showFileHistory: options.showFileHistory }); { showFileHistory: options.showFileHistory });

View File

@@ -5,6 +5,7 @@ import * as path from 'path';
interface IBlameEntry { interface IBlameEntry {
sha: string; sha: string;
line: number; line: number;
originalLine: number; originalLine: number;
lineCount: number; lineCount: number;
@@ -53,7 +54,7 @@ export class GitBlameParserEnricher implements IGitEnricher<IGitBlame> {
if (!entry) { if (!entry) {
entry = { entry = {
sha: lineParts[0].substring(0, 8), sha: lineParts[0],
originalLine: parseInt(lineParts[1], 10) - 1, originalLine: parseInt(lineParts[1], 10) - 1,
line: parseInt(lineParts[2], 10) - 1, line: parseInt(lineParts[2], 10) - 1,
lineCount: parseInt(lineParts[3], 10) lineCount: parseInt(lineParts[3], 10)
@@ -102,7 +103,7 @@ export class GitBlameParserEnricher implements IGitEnricher<IGitBlame> {
break; break;
case 'previous': case 'previous':
entry.previousSha = lineParts[1].substring(0, 8); entry.previousSha = lineParts[1];
entry.previousFileName = lineParts.slice(2).join(' '); entry.previousFileName = lineParts.slice(2).join(' ');
break; break;

View File

@@ -21,6 +21,8 @@ interface ILogEntry {
summary?: string; summary?: string;
} }
const shaRegex = /^[a-f0-9]{40}$/;
export class GitLogParserEnricher implements IGitEnricher<IGitLog> { export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
private _parseEntries(data: string, isRepoPath: boolean): ILogEntry[] { private _parseEntries(data: string, isRepoPath: boolean): ILogEntry[] {
@@ -40,9 +42,9 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
} }
if (!entry) { if (!entry) {
if (!/^[a-f0-9]{40}$/.test(lineParts[0])) continue; if (!shaRegex.test(lineParts[0])) continue;
entry = { entry = {
sha: lineParts[0].substring(0, 8) sha: lineParts[0]
}; };
continue; continue;

View File

@@ -115,9 +115,10 @@ export default class Git {
static async getVersionedFile(fileName: string, repoPath: string, sha: string) { static async getVersionedFile(fileName: string, repoPath: string, sha: string) {
const data = await Git.getVersionedFileText(fileName, repoPath, sha); const data = await Git.getVersionedFileText(fileName, repoPath, sha);
const shortSha = sha.substring(0, 8);
const ext = path.extname(fileName); const ext = path.extname(fileName);
return new Promise<string>((resolve, reject) => { return new Promise<string>((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) => { (err, destination, fd, cleanupCallback) => {
if (err) { if (err) {
reject(err); reject(err);

View File

@@ -80,6 +80,10 @@ export class GitCommit implements IGitCommit {
this.previousFileName = previousFileName; this.previousFileName = previousFileName;
} }
get shortSha() {
return this.sha.substring(0, 8);
}
get isUncommitted(): boolean { get isUncommitted(): boolean {
if (this._isUncommitted === undefined) { if (this._isUncommitted === undefined) {
this._isUncommitted = Git.isUncommitted(this.sha); this._isUncommitted = Git.isUncommitted(this.sha);
@@ -87,6 +91,10 @@ export class GitCommit implements IGitCommit {
return this._isUncommitted; return this._isUncommitted;
} }
get previousShortSha() {
return this.previousSha && this.previousSha.substring(0, 8);
}
get previousUri(): Uri { get previousUri(): Uri {
return this.previousFileName ? Uri.file(path.join(this.repoPath, this.previousFileName)) : this.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 { get nextUri(): Uri {
return this.nextFileName ? Uri.file(path.join(this.repoPath, this.nextFileName)) : this.uri; return this.nextFileName ? Uri.file(path.join(this.repoPath, this.nextFileName)) : this.uri;
} }

View File

@@ -49,6 +49,10 @@ export class GitUri extends Uri {
} }
} }
get shortSha() {
return this.sha && this.sha.substring(0, 8);
}
fileUri() { fileUri() {
return Uri.file(this.sha ? this.path : this.fsPath); return Uri.file(this.sha ? this.path : this.fsPath);
} }

View File

@@ -262,7 +262,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
const recentCommit = Iterables.first(blame.commits.values()); const recentCommit = Iterables.first(blame.commits.values());
title = `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`; title = `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`;
if (this._config.advanced.debug && this._config.advanced.output.level === OutputLevel.Verbose) { 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) { switch (this._config.codeLens.recentChange.command) {

View File

@@ -23,7 +23,7 @@ export class GitContentProvider implements TextDocumentContentProvider {
} }
catch (ex) { catch (ex) {
Logger.error('[GitLens.GitContentProvider]', 'getVersionedFileText', 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; return undefined;
} }
} }

View File

@@ -54,7 +54,7 @@ export class GitRevisionCodeLensProvider implements CodeLensProvider {
_resolveDiffWithWorkingTreeCodeLens(lens: GitDiffWithWorkingCodeLens, token: CancellationToken): Thenable<CodeLens> { _resolveDiffWithWorkingTreeCodeLens(lens: GitDiffWithWorkingCodeLens, token: CancellationToken): Thenable<CodeLens> {
lens.command = { lens.command = {
title: `Compare ${lens.commit.sha} with Working Tree`, title: `Compare ${lens.commit.shortSha} with Working Tree`,
command: Commands.DiffWithWorking, command: Commands.DiffWithWorking,
arguments: [ arguments: [
Uri.file(lens.fileName), Uri.file(lens.fileName),
@@ -67,7 +67,7 @@ export class GitRevisionCodeLensProvider implements CodeLensProvider {
_resolveGitDiffWithPreviousCodeLens(lens: GitDiffWithPreviousCodeLens, token: CancellationToken): Thenable<CodeLens> { _resolveGitDiffWithPreviousCodeLens(lens: GitDiffWithPreviousCodeLens, token: CancellationToken): Thenable<CodeLens> {
lens.command = { 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, command: Commands.DiffWithPrevious,
arguments: [ arguments: [
Uri.file(lens.fileName), Uri.file(lens.fileName),

View File

@@ -14,8 +14,8 @@ export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPi
const uris = commit.fileStatuses.map(_ => GitProvider.toGitContentUri(commit.sha, _.fileName, repoPath, commit.originalFileName)); const uris = commit.fileStatuses.map(_ => GitProvider.toGitContentUri(commit.sha, _.fileName, repoPath, commit.originalFileName));
super(uris, item || { super(uris, item || {
label: `$(file-symlink-file) Open Changed Files`, label: `$(file-symlink-file) Open Changed Files`,
description: `\u00a0 \u2014 \u00a0\u00a0 in \u00a0$(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.sha}` //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({ items.splice(index++, 0, new CommandQuickPickItem({
label: `$(clippy) Copy Commit Sha to Clipboard`, 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])); }, Commands.CopyShaToClipboard, [uri, commit.sha]));
items.splice(index++, 0, new CommandQuickPickItem({ items.splice(index++, 0, new CommandQuickPickItem({
@@ -52,12 +52,12 @@ export class CommitDetailsQuickPick {
items.splice(index++, 0, new CommandQuickPickItem({ items.splice(index++, 0, new CommandQuickPickItem({
label: `$(git-compare) Directory Compare with Previous Commit`, 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])); }, Commands.DiffDirectory, [commit.uri, commit.previousSha || `${commit.sha}^`, commit.sha]));
items.splice(index++, 0, new CommandQuickPickItem({ items.splice(index++, 0, new CommandQuickPickItem({
label: `$(git-compare) Directory Compare with Working Tree`, 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])); }, Commands.DiffDirectory, [uri, commit.sha]));
items.splice(index++, 0, new CommandQuickPickItem({ items.splice(index++, 0, new CommandQuickPickItem({
@@ -77,7 +77,7 @@ export class CommitDetailsQuickPick {
const pick = await window.showQuickPick(items, { const pick = await window.showQuickPick(items, {
matchOnDescription: true, matchOnDescription: true,
matchOnDetail: 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(), ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => { onDidSelectItem: (item: QuickPickItem) => {
Keyboard.instance.setKeyCommand('right', item); Keyboard.instance.setKeyCommand('right', item);

View File

@@ -13,7 +13,7 @@ export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPick
const uri = GitProvider.toGitContentUri(commit); const uri = GitProvider.toGitContentUri(commit);
super(uri, item || { super(uri, item || {
label: `$(file-symlink-file) Open File`, 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) { if (!options.showFileHistory) {
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(git-commit) Show Commit Details`, 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])); }, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), commit.sha, commit, currentCommand]));
} }
if (commit.previousSha) { if (commit.previousSha) {
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(git-compare) Compare with Previous Commit`, 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])); }, Commands.DiffWithPrevious, [commit.uri, commit]));
} }
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(git-compare) Compare with Working Tree`, 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])); }, Commands.DiffWithWorking, [uri, commit]));
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(clippy) Copy Commit Sha to Clipboard`, 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])); }, Commands.CopyShaToClipboard, [uri, commit.sha]));
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
@@ -86,7 +86,7 @@ export class CommitFileDetailsQuickPick {
items.push(new CommandQuickPickItem({ items.push(new CommandQuickPickItem({
label: `$(history) Show ${workingFileName && options.showFileHistory ? 'Previous ' : ''}File History`, 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])); }, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand]));
if (goBackCommand) { if (goBackCommand) {
@@ -97,7 +97,7 @@ export class CommitFileDetailsQuickPick {
const pick = await window.showQuickPick(items, { const pick = await window.showQuickPick(items, {
matchOnDescription: true, 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(), ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => { onDidSelectItem: (item: QuickPickItem) => {
Keyboard.instance.setKeyCommand('right', item); Keyboard.instance.setKeyCommand('right', item);

View File

@@ -48,7 +48,7 @@ export class FileHistoryQuickPick {
const pick = await window.showQuickPick(items, { const pick = await window.showQuickPick(items, {
matchOnDescription: true, matchOnDescription: true,
matchOnDetail: true, matchOnDetail: true,
placeHolder: `${commit.getFormattedPath()}${sha ? ` \u00a0\u2022\u00a0 ${sha}` : ''}`, placeHolder: `${commit.getFormattedPath()}${sha ? ` \u00a0\u2022\u00a0 ${sha.substring(0, 8)}` : ''}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(), ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => { onDidSelectItem: (item: QuickPickItem) => {
Keyboard.instance.setKeyCommand('right', item); Keyboard.instance.setKeyCommand('right', item);

View File

@@ -13,7 +13,7 @@ export class CommitQuickPickItem implements QuickPickItem {
constructor(public commit: GitCommit, descriptionSuffix: string = '') { constructor(public commit: GitCommit, descriptionSuffix: string = '') {
this.label = `${commit.author}, ${moment(commit.date).fromNow()}`; 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; this.detail = commit.message;
} }
} }
@@ -23,6 +23,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
fileName: string; fileName: string;
gitUri: GitUri; gitUri: GitUri;
sha: string; sha: string;
shortSha: string;
status: GitFileStatus; status: GitFileStatus;
constructor(commit: GitCommit, fileName: string, status: GitFileStatus) { constructor(commit: GitCommit, fileName: string, status: GitFileStatus) {
@@ -41,6 +42,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
this.fileName = fileName; this.fileName = fileName;
this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, fileName))); this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, fileName)));
this.sha = commit.sha; this.sha = commit.sha;
this.shortSha = commit.shortSha;
this.status = status; this.status = status;
} }
} }