Browse Source

Changes behavior of showing uncommit changes

Now shows the previous commit details
main
Eric Amodio 7 years ago
parent
commit
1263064150
2 changed files with 13 additions and 4 deletions
  1. +12
    -3
      src/commands/quickPicks.ts
  2. +1
    -1
      src/commands/showQuickCommitDetails.ts

+ 12
- 3
src/commands/quickPicks.ts View File

@ -3,7 +3,7 @@ import { Iterables } from '../system';
import { QuickPickOptions, Uri, window, workspace } from 'vscode';
import { IAdvancedConfig } from '../configuration';
import { Commands } from '../constants';
import { GitCommit, GitUri, IGitLog } from '../gitProvider';
import GitProvider, { GitCommit, GitUri, IGitLog } from '../gitProvider';
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './quickPickItems';
import * as moment from 'moment';
import * as path from 'path';
@ -14,9 +14,18 @@ function getQuickPickIgnoreFocusOut() {
export class CommitQuickPick {
static async show(commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
static async show(git: GitProvider, commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
const items: CommandQuickPickItem[] = [];
const isUncommitted = commit.isUncommitted;
if (isUncommitted) {
// Since we can't trust the previous sha on an uncommitted commit, find the last commit for this file
const log = await git.getLogForFile(commit.uri.fsPath, undefined, undefined, undefined, 2);
if (!log) return undefined;
commit = Iterables.first(log.commits.values());
}
if (commit.previousSha) {
items.push(new CommandQuickPickItem({
label: `$(git-compare) Compare with Previous Commit`,
@ -71,7 +80,7 @@ export class CommitQuickPick {
return await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`,
placeHolder: `${commit.fileName} \u2022 ${isUncommitted ? 'Uncommitted changes showing ' : '' } ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut()
} as QuickPickOptions);
}

+ 1
- 1
src/commands/showQuickCommitDetails.ts View File

@ -80,7 +80,7 @@ export default class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
workingFileName = !workingCommit ? commit.fileName : undefined;
}
pick = await CommitQuickPick.show(commit, workingFileName, uri,
pick = await CommitQuickPick.show(this.git, commit, workingFileName, uri,
// Create a command to get back to where we are right now
new CommandQuickPickItem({
label: `go back \u21A9`,

Loading…
Cancel
Save