Преглед на файлове

Adds Working Tree to branch/tag compare quickpick

main
Eric Amodio преди 5 години
родител
ревизия
b7686f1c0b
променени са 7 файла, в които са добавени 66 реда и са изтрити 18 реда
  1. +3
    -2
      src/commands/diffBranchWith.ts
  2. +2
    -2
      src/commands/openBranchInRemote.ts
  3. +2
    -2
      src/commands/openFileInRemote.ts
  4. +7
    -2
      src/commands/showQuickBranchHistory.ts
  5. +25
    -1
      src/quickpicks/gitQuickPicks.ts
  6. +22
    -6
      src/quickpicks/referencesQuickPick.ts
  7. +5
    -3
      src/views/nodes/compareNode.ts

+ 3
- 2
src/commands/diffBranchWith.ts Целия файл

@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick, ReferencesQuickPickIncludes } from '../quickpicks';
import {
ActiveEditorCommand,
command,
@ -80,7 +80,8 @@ export class DiffBranchWithCommand extends ActiveEditorCommand {
const pick = await new ReferencesQuickPick(repoPath).show(placeHolder, {
allowEnteringRefs: true,
checked: args.ref1,
checkmarks: checkmarks
checkmarks: checkmarks,
include: ReferencesQuickPickIncludes.BranchesAndTags | ReferencesQuickPickIncludes.WorkingTree
});
if (pick === undefined) return undefined;

+ 2
- 2
src/commands/openBranchInRemote.ts Целия файл

@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitUri, RemoteResourceType } from '../git/gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick, ReferencesQuickPickIncludes } from '../quickpicks';
import {
ActiveEditorCommand,
command,
@ -59,7 +59,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
autoPick: true,
checkmarks: false,
filterBranches: b => b.tracking !== undefined,
include: 'branches'
include: ReferencesQuickPickIncludes.Branches
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return undefined;

+ 2
- 2
src/commands/openFileInRemote.ts Целия файл

@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitService, GitUri, RemoteResourceType } from '../git/gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick, ReferencesQuickPickIncludes } from '../quickpicks';
import {
ActiveEditorCommand,
command,
@ -88,7 +88,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
autoPick: true,
checkmarks: false,
filterBranches: b => b.tracking !== undefined,
include: 'branches'
include: ReferencesQuickPickIncludes.Branches
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return undefined;

+ 7
- 2
src/commands/showQuickBranchHistory.ts Целия файл

@ -5,7 +5,12 @@ import { Container } from '../container';
import { GitLog, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchHistoryQuickPick, CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import {
BranchHistoryQuickPick,
CommandQuickPickItem,
ReferencesQuickPick,
ReferencesQuickPickIncludes
} from '../quickpicks';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
@ -62,7 +67,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
{
checkmarks: false,
goBack: goBackCommand,
include: 'branches'
include: ReferencesQuickPickIncludes.Branches
}
);
if (pick === undefined) return undefined;

+ 25
- 1
src/quickpicks/gitQuickPicks.ts Целия файл

@ -205,7 +205,31 @@ export interface RefQuickPickItem extends QuickPickItemOfT {
}
export namespace RefQuickPickItem {
export function create(ref: string, picked?: boolean, options: { ref?: boolean } = {}) {
export function create(ref: string, picked?: boolean, options: { ref?: boolean } = {}): RefQuickPickItem {
if (ref === '') {
return {
label: `${Strings.pad('$(file-directory)', 0, 2)}Working Tree`,
description: '',
picked: picked,
item: GitReference.create(ref, { name: 'Working Tree' }),
current: false,
ref: ref,
remote: false
};
}
if (ref === 'HEAD') {
return {
label: 'HEAD',
description: '',
picked: picked,
item: GitReference.create(ref, { name: 'HEAD' }),
current: false,
ref: ref,
remote: false
};
}
const gitRef = GitReference.create(ref);
const item: RefQuickPickItem = {

+ 22
- 6
src/quickpicks/referencesQuickPick.ts Целия файл

@ -9,6 +9,14 @@ import { BranchQuickPickItem, RefQuickPickItem, TagQuickPickItem } from './gitQu
export type ReferencesQuickPickItem = BranchQuickPickItem | TagQuickPickItem | RefQuickPickItem;
export enum ReferencesQuickPickIncludes {
Branches = 1,
Tags = 2,
WorkingTree = 4,
BranchesAndTags = 3
}
export interface ReferencesQuickPickOptions {
allowEnteringRefs?: boolean;
autoPick?: boolean;
@ -17,7 +25,7 @@ export interface ReferencesQuickPickOptions {
filterBranches?(branch: GitBranch): boolean;
filterTags?(tag: GitTag): boolean;
goBack?: CommandQuickPickItem;
include?: 'branches' | 'tags' | 'all';
include?: ReferencesQuickPickIncludes;
}
export class ReferencesQuickPick {
@ -25,11 +33,15 @@ export class ReferencesQuickPick {
async show(
placeHolder: string,
options?: Exclude<ReferencesQuickPickOptions, CommandQuickPickItem> & { include: 'branches' }
options?: Exclude<ReferencesQuickPickOptions, CommandQuickPickItem> & {
include: ReferencesQuickPickIncludes.Branches;
}
): Promise<BranchQuickPickItem | undefined>;
async show(
placeHolder: string,
options?: Exclude<ReferencesQuickPickOptions, CommandQuickPickItem> & { include: 'tags' }
options?: Exclude<ReferencesQuickPickOptions, CommandQuickPickItem> & {
include: ReferencesQuickPickIncludes.Tags;
}
): Promise<TagQuickPickItem | undefined>;
async show(
placeHolder: string,
@ -137,17 +149,17 @@ export class ReferencesQuickPick {
{ checked, checkmarks, filterBranches, filterTags, goBack, include, ...options }: ReferencesQuickPickOptions,
token: CancellationToken
): Promise<(BranchQuickPickItem | TagQuickPickItem | CommandQuickPickItem)[]> {
include = include || 'all';
include = include || ReferencesQuickPickIncludes.BranchesAndTags;
const results = await Promises.cancellable(
Promise.all<GitBranch[] | undefined, GitTag[] | undefined>([
include === 'all' || include === 'branches'
include & ReferencesQuickPickIncludes.Branches
? Container.git.getBranches(this.repoPath, {
...options,
filter: filterBranches && filterBranches
})
: undefined,
include === 'all' || include === 'tags'
include & ReferencesQuickPickIncludes.Tags
? Container.git.getTags(this.repoPath, {
...options,
filter: filterTags && filterTags,
@ -207,6 +219,10 @@ export class ReferencesQuickPick {
}
}
if (include & ReferencesQuickPickIncludes.WorkingTree) {
(items as QuickPickItem[]).splice(0, 0, RefQuickPickItem.create('', undefined));
}
if (goBack !== undefined) {
(items as QuickPickItem[]).splice(0, 0, goBack);
}

+ 5
- 3
src/views/nodes/compareNode.ts Целия файл

@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { getRepoPathOrPrompt } from '../../commands';
import { CommandContext, GlyphChars, NamedRef, setCommandContext } from '../../constants';
import { GitService } from '../../git/gitService';
import { ReferencesQuickPick } from '../../quickpicks';
import { ReferencesQuickPick, ReferencesQuickPickIncludes } from '../../quickpicks';
import { debug, gate, Iterables, log, Promises } from '../../system';
import { CompareView } from '../compareView';
import { MessageNode } from './common';
@ -143,7 +143,8 @@ export class CompareNode extends ViewNode {
allowEnteringRefs: true,
checked:
typeof this._selectedRef.ref === 'string' ? this._selectedRef.ref : this._selectedRef.ref.ref,
checkmarks: true
checkmarks: true,
include: ReferencesQuickPickIncludes.BranchesAndTags | ReferencesQuickPickIncludes.WorkingTree
}
);
if (pick === undefined) {
@ -179,7 +180,8 @@ export class CompareNode extends ViewNode {
if (ref === undefined) {
const pick = await new ReferencesQuickPick(repoPath).show(`Compare${GlyphChars.Ellipsis}`, {
allowEnteringRefs: true,
checkmarks: false
checkmarks: false,
include: ReferencesQuickPickIncludes.BranchesAndTags | ReferencesQuickPickIncludes.WorkingTree
});
if (pick === undefined) {
await this.view.show();

Зареждане…
Отказ
Запис