Bläddra i källkod

Adds branch quick pick to directory compare command

main
Eric Amodio 7 år sedan
förälder
incheckning
343d2f9be1
3 ändrade filer med 18 tillägg och 7 borttagningar
  1. +14
    -2
      src/commands/diffDirectory.ts
  2. +1
    -1
      src/commands/diffWithBranch.ts
  3. +3
    -4
      src/quickPicks/branches.ts

+ 14
- 2
src/commands/diffDirectory.ts Visa fil

@ -1,8 +1,10 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, BranchesQuickPick } from '../quickPicks';
export class DiffDirectoryCommand extends ActiveEditorCommand {
@ -20,8 +22,18 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
if (!repoPath) return window.showWarningMessage(`Unable to open directory diff`);
if (!shaOrBranch1) {
//window.showQuickPick()
return undefined;
const branches = await this.git.getBranches(repoPath);
const current = Iterables.find(branches, _ => _.current);
const pick = await BranchesQuickPick.show(branches, `Compare ${current.name} to \u2026`);
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
}
shaOrBranch1 = pick.branch.name;
if (!shaOrBranch1) return undefined;
}
this.git.openDirectoryDiff(repoPath, shaOrBranch1, shaOrBranch2);

+ 1
- 1
src/commands/diffWithBranch.ts Visa fil

@ -24,7 +24,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
const gitUri = await GitUri.fromUri(uri, this.git);
const branches = await this.git.getBranches(gitUri.repoPath);
const pick = await BranchesQuickPick.show(branches, gitUri, goBackCommand);
const pick = await BranchesQuickPick.show(branches, `Compare ${path.basename(gitUri.fsPath)} to \u2026`, goBackCommand);
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {

+ 3
- 4
src/quickPicks/branches.ts Visa fil

@ -1,8 +1,7 @@
'use strict';
import { QuickPickItem, QuickPickOptions, window } from 'vscode';
import { GitBranch, GitUri } from '../gitService';
import { GitBranch } from '../gitService';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
import * as path from 'path';
export class BranchQuickPickItem implements QuickPickItem {
@ -18,7 +17,7 @@ export class BranchQuickPickItem implements QuickPickItem {
export class BranchesQuickPick {
static async show(branches: GitBranch[], uri: GitUri, goBackCommand?: CommandQuickPickItem): Promise<BranchQuickPickItem | CommandQuickPickItem | undefined> {
static async show(branches: GitBranch[], placeHolder: string, goBackCommand?: CommandQuickPickItem): Promise<BranchQuickPickItem | CommandQuickPickItem | undefined> {
const items = branches.map(_ => new BranchQuickPickItem(_)) as (BranchQuickPickItem | CommandQuickPickItem)[];
@ -30,7 +29,7 @@ export class BranchesQuickPick {
const pick = await window.showQuickPick(items,
{
placeHolder: `Compare ${path.basename(uri.fsPath)} to \u2026`,
placeHolder: placeHolder,
ignoreFocusOut: getQuickPickIgnoreFocusOut()
} as QuickPickOptions);
if (!pick) return undefined;

Laddar…
Avbryt
Spara