mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds branch quick pick to directory compare command
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
import { Iterables } from '../system';
|
||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from './commands';
|
import { ActiveEditorCommand, Commands } from './commands';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { CommandQuickPickItem, BranchesQuickPick } from '../quickPicks';
|
||||||
|
|
||||||
export class DiffDirectoryCommand extends ActiveEditorCommand {
|
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 (!repoPath) return window.showWarningMessage(`Unable to open directory diff`);
|
||||||
|
|
||||||
if (!shaOrBranch1) {
|
if (!shaOrBranch1) {
|
||||||
//window.showQuickPick()
|
const branches = await this.git.getBranches(repoPath);
|
||||||
return undefined;
|
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);
|
this.git.openDirectoryDiff(repoPath, shaOrBranch1, shaOrBranch2);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
|
|||||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||||
|
|
||||||
const branches = await this.git.getBranches(gitUri.repoPath);
|
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) return undefined;
|
||||||
|
|
||||||
if (pick instanceof CommandQuickPickItem) {
|
if (pick instanceof CommandQuickPickItem) {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { QuickPickItem, QuickPickOptions, window } from 'vscode';
|
import { QuickPickItem, QuickPickOptions, window } from 'vscode';
|
||||||
import { GitBranch, GitUri } from '../gitService';
|
import { GitBranch } from '../gitService';
|
||||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
|
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export class BranchQuickPickItem implements QuickPickItem {
|
export class BranchQuickPickItem implements QuickPickItem {
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ export class BranchQuickPickItem implements QuickPickItem {
|
|||||||
|
|
||||||
export class BranchesQuickPick {
|
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)[];
|
const items = branches.map(_ => new BranchQuickPickItem(_)) as (BranchQuickPickItem | CommandQuickPickItem)[];
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ export class BranchesQuickPick {
|
|||||||
|
|
||||||
const pick = await window.showQuickPick(items,
|
const pick = await window.showQuickPick(items,
|
||||||
{
|
{
|
||||||
placeHolder: `Compare ${path.basename(uri.fsPath)} to \u2026`,
|
placeHolder: placeHolder,
|
||||||
ignoreFocusOut: getQuickPickIgnoreFocusOut()
|
ignoreFocusOut: getQuickPickIgnoreFocusOut()
|
||||||
} as QuickPickOptions);
|
} as QuickPickOptions);
|
||||||
if (!pick) return undefined;
|
if (!pick) return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user