Parcourir la source

Adds compare working tree to branch/tag command

main
Eric Amodio il y a 6 ans
Parent
révision
3d994bd0cf
5 fichiers modifiés avec 68 ajouts et 17 suppressions
  1. +3
    -1
      CHANGELOG.md
  2. +5
    -0
      README.md
  3. +9
    -0
      package.json
  4. +1
    -0
      src/commands/common.ts
  5. +50
    -16
      src/commands/diffBranchWithBranch.ts

+ 3
- 1
CHANGELOG.md Voir le fichier

@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds `gitlens.statusBar.reduceFlicker` setting to specify whether to reduce the status bar "flickering" when changing lines by not first clearing the previous blame information -- closes [#272](https://github.com/eamodio/vscode-gitlens/issues/272)
- Adds `gitlens.statusBar.reduceFlicker` setting to specify whether to reduce the status bar "flickering" when changing lines by not first clearing the previous blame information — closes [#272](https://github.com/eamodio/vscode-gitlens/issues/272)
- Adds *Compare Index (HEAD) with Branch or Tag...* (`gitlens.explorers.diffHeadWithBranch`) command - compares the index (HEAD) to the selected branch or tag — thanks to [PR #278](https://github.com/eamodio/vscode-gitlens/pull/278) by Geoffrey ([@g3offrey](https://github.com/g3offrey))!
- Adds *Compare Working Tree with Branch or Tag...* (`gitlens.explorers.diffWorkingWithBranch`) command - compares the working tree to the selected branch or tag
- Adds the *Open File* (`gitlens.explorers.openFile`) command to the *GitLens* explorer inline for file nodes
- Adds the *Clear Results* (`gitlen.resultsExplorer.clearResultsNode`) command to the *GitLens Results* view inline for results nodes
- Adds *Push to Commit (via Terminal)* (`gitlens.explorers.terminalPushCommit`) command to commit nodes on the current branch in the *GitLens* explorer

+ 5
- 0
README.md Voir le fichier

@ -451,6 +451,10 @@ An on-demand, [customizable](#gitlens-results-view-settings "Jump to the GitLens
- Adds a *Directory Compare Working Tree with...* command (`gitlens.diffDirectory`) to open the configured Git difftool to compare the working tree with the selected branch or tag
- Adds a *Compare Index (HEAD) with Branch or Tag...* command (`gitlens.diffHeadWithBranch`) to compare the index (HEAD) with the selected branch or tag
- Adds a *Compare Working Tree with Branch or Tag...* command (`gitlens.diffWorkingWithBranch`) to compare the working tree with the selected branch or tag
- Adds a *Compare File with Branch or Tag...* command (`gitlens.diffWithBranch`) to compare the active file with the same file on the selected branch or tag
- Adds a *Compare File with Next Revision* command (`gitlens.diffWithNext`) with a shortcut of `alt+.` to compare the active file/diff with the next commit revision
@ -667,6 +671,7 @@ Add [`"gitlens.insiders": true`](#general-settings "Jump to GitLens settings") t
A big thanks to the people that have contributed to this project:
- Amanda Cameron ([@AmandaCameron](https://github.com/AmandaCameron)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=AmandaCameron))
- Geoffrey ([@g3offrey](https://github.com/g3offrey)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=g3offrey))
- Yukai Huang ([@Yukaii](https://github.com/Yukaii)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=Yukaii))
- Helmut Januschka ([@hjanuschka](https://github.com/hjanuschka)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=hjanuschka))
- Chris Kaczor ([@ckaczor](https://github.com/ckaczor)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=ckaczor))

+ 9
- 0
package.json Voir le fichier

@ -1107,6 +1107,11 @@
"category": "GitLens"
},
{
"command": "gitlens.diffWorkingWithBranch",
"title": "Compare Working Tree with Branch or Tag...",
"category": "GitLens"
},
{
"command": "gitlens.diffWith",
"title": "Compare File Revisions",
"category": "GitLens"
@ -1662,6 +1667,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffWorkingWithBranch",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffWith",
"when": "false"
},

+ 1
- 0
src/commands/common.ts Voir le fichier

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

+ 50
- 16
src/commands/diffBranchWithBranch.ts Voir le fichier

@ -1,19 +1,40 @@
'use strict';
import { CancellationTokenSource, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, CommandContext, 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 interface DiffBranchWithBranchCommandArgs {
ref1?: string;
ref2?: string;
}
export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffHeadWithBranch);
super([Commands.DiffHeadWithBranch, Commands.DiffWorkingWithBranch]);
}
async execute(editor?: TextEditor, uri?: Uri): Promise<any> {
protected async preExecute(context: CommandContext, args: DiffBranchWithBranchCommandArgs = {}): Promise<any> {
switch (context.command) {
case Commands.DiffHeadWithBranch:
args.ref2 = 'HEAD';
break;
case Commands.DiffWorkingWithBranch:
args.ref2 = '';
break;
}
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffBranchWithBranchCommandArgs = {}): Promise<any> {
if (args.ref2 === undefined) return;
uri = getCommandUri(uri, editor);
let progressCancellation: CancellationTokenSource | undefined;
@ -22,26 +43,39 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
const repoPath = await Container.git.getRepoPath(uri);
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open branch compare`);
const placeHolder = `Compare Index (HEAD) to ${GlyphChars.Ellipsis}`;
if (!args.ref1) {
let placeHolder;
switch (args.ref2) {
case '':
placeHolder = `Compare Working Tree to ${GlyphChars.Ellipsis}`;
break;
case 'HEAD':
placeHolder = `Compare Index (HEAD) to ${GlyphChars.Ellipsis}`;
break;
default:
placeHolder = `Compare ${args.ref2} to ${GlyphChars.Ellipsis}`;
break;
}
progressCancellation = BranchesAndTagsQuickPick.showProgress(placeHolder);
progressCancellation = BranchesAndTagsQuickPick.showProgress(placeHolder);
const [branches, tags] = await Promise.all([
Container.git.getBranches(repoPath),
Container.git.getTags(repoPath)
]);
const [branches, tags] = await Promise.all([
Container.git.getBranches(repoPath),
Container.git.getTags(repoPath)
]);
if (progressCancellation.token.isCancellationRequested) return undefined;
if (progressCancellation.token.isCancellationRequested) return undefined;
const pick = await BranchesAndTagsQuickPick.show(branches, tags, placeHolder, { progressCancellation: progressCancellation });
if (pick === undefined) return undefined;
const pick = await BranchesAndTagsQuickPick.show(branches, tags, placeHolder, { progressCancellation: progressCancellation });
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
if (pick instanceof CommandQuickPickItem) return pick.execute();
const compareWith = pick.name;
if (compareWith === undefined) return undefined;
args.ref1 = pick.name;
if (args.ref1 === undefined) return undefined;
}
Container.resultsExplorer.showComparisonInResults(repoPath, compareWith, 'HEAD');
Container.resultsExplorer.showComparisonInResults(repoPath, args.ref1, args.ref2);
return undefined;
}

Chargement…
Annuler
Enregistrer