ソースを参照

Add new command to diff HEAD with branch using command palette

main
Geoffrey 6年前
committed by Eric Amodio
コミット
dd3768fa33
4個のファイルの変更66行の追加0行の削除
  1. +9
    -0
      package.json
  2. +2
    -0
      src/commands.ts
  3. +1
    -0
      src/commands/common.ts
  4. +54
    -0
      src/commands/diffHeadWithBranch.ts

+ 9
- 0
package.json ファイルの表示

@ -1102,6 +1102,11 @@
"category": "GitLens"
},
{
"command": "gitlens.diffHeadWithBranch",
"title": "Compare Index (HEAD) with Branch or Tag...",
"category": "GitLens"
},
{
"command": "gitlens.diffWith",
"title": "Compare File Revisions",
"category": "GitLens"
@ -1653,6 +1658,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffHeadWithBranch",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffWith",
"when": "false"
},

+ 2
- 0
src/commands.ts ファイルの表示

@ -9,6 +9,7 @@ export * from './commands/closeUnchangedFiles';
export * from './commands/copyMessageToClipboard';
export * from './commands/copyShaToClipboard';
export * from './commands/diffDirectory';
export * from './commands/diffHeadWithBranch';
export * from './commands/diffLineWithPrevious';
export * from './commands/diffLineWithWorking';
export * from './commands/diffWith';
@ -59,6 +60,7 @@ export function configureCommands(): void {
Container.context.subscriptions.push(new Commands.CopyMessageToClipboardCommand());
Container.context.subscriptions.push(new Commands.CopyShaToClipboardCommand());
Container.context.subscriptions.push(new Commands.DiffDirectoryCommand());
Container.context.subscriptions.push(new Commands.DiffHeadWithBranchCommand());
Container.context.subscriptions.push(new Commands.DiffLineWithPreviousCommand());
Container.context.subscriptions.push(new Commands.DiffLineWithWorkingCommand());
Container.context.subscriptions.push(new Commands.DiffWithCommand());

+ 1
- 0
src/commands/common.ts ファイルの表示

@ -12,6 +12,7 @@ export enum Commands {
CopyMessageToClipboard = 'gitlens.copyMessageToClipboard',
CopyShaToClipboard = 'gitlens.copyShaToClipboard',
DiffDirectory = 'gitlens.diffDirectory',
DiffHeadWithBranch = 'gitlens.diffHeadWithBranch',
ExternalDiffAll = 'gitlens.externalDiffAll',
DiffWith = 'gitlens.diffWith',
DiffWithBranch = 'gitlens.diffWithBranch',

+ 54
- 0
src/commands/diffHeadWithBranch.ts ファイルの表示

@ -0,0 +1,54 @@
'use strict';
import { CancellationTokenSource, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks';
export class DiffHeadWithBranchCommand extends ActiveEditorCommand {
constructor() {
super([Commands.DiffHeadWithBranch]);
}
async execute(editor?: TextEditor, uri?: Uri): Promise<any> {
uri = getCommandUri(uri, editor);
let progressCancellation: CancellationTokenSource | undefined;
try {
const repoPath = await Container.git.getRepoPath(uri);
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open directory compare`);
const placeHolder = `Compare Index (HEAD) to ${GlyphChars.Ellipsis}`;
progressCancellation = BranchesAndTagsQuickPick.showProgress(placeHolder);
const [branches, tags] = await Promise.all([
Container.git.getBranches(repoPath),
Container.git.getTags(repoPath)
]);
if (progressCancellation.token.isCancellationRequested) return undefined;
const pick = await BranchesAndTagsQuickPick.show(branches, tags, placeHolder, { progressCancellation: progressCancellation });
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
const compareWith = pick.name;
if (compareWith === undefined) return undefined;
Container.resultsExplorer.showComparisonInResults(repoPath, compareWith, 'HEAD');
return undefined;
} catch (ex) {
Logger.error(ex, 'DiffHeadWithBranchCommand');
return window.showErrorMessage(`Unable to open directory compare. See output channel for more details`);
} finally {
progressCancellation && progressCancellation.dispose();
}
}
}

読み込み中…
キャンセル
保存