Browse Source

Removes "Comparing" from branch compare node

Changes upstream arrows
main
Eric Amodio 5 years ago
parent
commit
da7a95e8c1
7 changed files with 81 additions and 23 deletions
  1. +1
    -1
      src/commands/openBranchInRemote.ts
  2. +13
    -2
      src/git/models/branch.ts
  3. +1
    -1
      src/quickpicks/repoStatusQuickPick.ts
  4. +35
    -5
      src/views/nodes/branchNode.ts
  5. +6
    -1
      src/views/nodes/compareBranchNode.ts
  6. +23
    -11
      src/views/nodes/remoteNode.ts
  7. +2
    -2
      src/views/viewCommands.ts

+ 1
- 1
src/commands/openBranchInRemote.ts View File

@ -31,7 +31,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
if (isCommandViewContextWithBranch(context)) {
args = { ...args };
args.branch = context.node.branch.name;
args.remote = context.node.branch.getRemote();
args.remote = context.node.branch.getRemoteName();
}
return this.execute(context.editor, context.uri, args);

+ 13
- 2
src/git/models/branch.ts View File

@ -1,7 +1,7 @@
'use strict';
import { StarredBranches, WorkspaceState } from '../../constants';
import { Container } from '../../container';
import { Git } from '../git';
import { Git, GitRemote } from '../git';
import { GitStatus } from './status';
import { memoize } from '../../system';
@ -58,7 +58,18 @@ export class GitBranch {
}
@memoize()
getRemote(): string | undefined {
async getRemote(): Promise<GitRemote | undefined> {
const remoteName = this.getRemoteName();
if (remoteName === undefined) return undefined;
const remotes = await Container.git.getRemotes(this.repoPath);
if (remotes.length === 0) return undefined;
return remotes.find(r => r.name === remoteName);
}
@memoize()
getRemoteName(): string | undefined {
if (this.remote) return GitBranch.getRemote(this.name);
if (this.tracking !== undefined) return GitBranch.getRemote(this.tracking);

+ 1
- 1
src/quickpicks/repoStatusQuickPick.ts View File

@ -434,7 +434,7 @@ export class RepoStatusQuickPick {
const pick = await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `status of ${status.branch}${
status.upstream ? ` ${Strings.pad(GlyphChars.ArrowLeftRightLong, 1, 1)} ${status.upstream}` : ''
status.upstream ? ` ${Strings.pad(GlyphChars.ArrowsRightLeft, 1, 1)} ${status.upstream}` : ''
}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {

+ 35
- 5
src/views/nodes/branchNode.ts View File

@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ViewBranchesLayout } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranch, GitUri } from '../../git/gitService';
import { GitBranch, GitRemoteType, GitUri } from '../../git/gitService';
import { debug, gate, Iterables, log } from '../../system';
import { RepositoriesView } from '../repositoriesView';
import { BranchTrackingStatusNode } from './branchTrackingStatusNode';
@ -104,7 +104,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
return this._children;
}
getTreeItem(): TreeItem {
async getTreeItem(): Promise<TreeItem> {
const name = this.label;
let tooltip = `${this.branch.getName()}${this.current ? ' (current)' : ''}`;
let iconSuffix = '';
@ -112,9 +112,39 @@ export class BranchNode extends ViewRefNode implements Pageabl
let description;
if (!this.branch.remote && this.branch.tracking !== undefined) {
if (this.view.config.showTrackingBranch) {
description = `${this.branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${
GlyphChars.ArrowLeftRightLong
}${GlyphChars.Space} ${this.branch.tracking}`;
let arrows = GlyphChars.Dash;
const remote = await this.branch.getRemote();
if (remote !== undefined) {
let left;
let right;
for (const { type } of remote.types) {
if (type === GitRemoteType.Fetch) {
left = true;
if (right) break;
}
else if (type === GitRemoteType.Push) {
right = true;
if (left) break;
}
}
if (left && right) {
arrows = GlyphChars.ArrowsRightLeft;
}
else if (right) {
arrows = GlyphChars.ArrowRight;
}
else if (left) {
arrows = GlyphChars.ArrowLeft;
}
}
description = `${this.branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${arrows}${
GlyphChars.Space
} ${this.branch.tracking}`;
}
tooltip += ` is tracking ${this.branch.tracking}\n${this.branch.getTrackingStatus({
empty: 'up-to-date',

+ 6
- 1
src/views/nodes/compareBranchNode.ts View File

@ -53,12 +53,16 @@ export class CompareBranchNode extends ViewNode {
getTreeItem(): TreeItem {
let state: TreeItemCollapsibleState;
let label;
let description;
if (this._compareWith === undefined) {
label = `Compare ${this.branch.name} with <branch, tag, or ref>`;
state = TreeItemCollapsibleState.None;
}
else {
label = `Comparing ${this.branch.name} to ${GitService.shortenSha(this._compareWith, {
label = `${this.branch.name}`;
description = `${GlyphChars.ArrowLeftRightLong}${
GlyphChars.Space
} ${GitService.shortenSha(this._compareWith, {
working: 'Working Tree'
})}`;
state = TreeItemCollapsibleState.Collapsed;
@ -71,6 +75,7 @@ export class CompareBranchNode extends ViewNode {
arguments: [() => this.compareWith()]
};
item.contextValue = ResourceType.CompareBranch;
item.description = description;
item.iconPath = {
dark: Container.context.asAbsolutePath('images/dark/icon-compare-refs.svg'),
light: Container.context.asAbsolutePath('images/light/icon-compare-refs.svg')

+ 23
- 11
src/views/nodes/remoteNode.ts View File

@ -70,28 +70,40 @@ export class RemoteNode extends ViewNode {
}
getTreeItem(): TreeItem {
const fetch = this.remote.types.find(rt => rt.type === GitRemoteType.Fetch);
const push = this.remote.types.find(rt => rt.type === GitRemoteType.Push);
let arrows;
let left;
let right;
for (const { type } of this.remote.types) {
if (type === GitRemoteType.Fetch) {
left = true;
if (right) break;
}
else if (type === GitRemoteType.Push) {
right = true;
if (left) break;
}
}
let separator;
if (fetch && push) {
separator = GlyphChars.ArrowLeftRightLong;
if (left && right) {
arrows = GlyphChars.ArrowsRightLeft;
}
else if (fetch) {
separator = GlyphChars.ArrowLeft;
else if (right) {
arrows = GlyphChars.ArrowRight;
}
else if (push) {
separator = GlyphChars.ArrowRight;
else if (left) {
arrows = GlyphChars.ArrowLeft;
}
else {
separator = GlyphChars.Dash;
arrows = GlyphChars.Dash;
}
const item = new TreeItem(
`${this.remote.default ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${this.remote.name}`,
TreeItemCollapsibleState.Collapsed
);
item.description = `${separator}${GlyphChars.Space} ${
item.description = `${arrows}${GlyphChars.Space} ${
this.remote.provider !== undefined ? this.remote.provider.name : this.remote.domain
} ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} ${
this.remote.provider !== undefined ? this.remote.provider.displayPath : this.remote.path

+ 2
- 2
src/views/viewCommands.ts View File

@ -625,7 +625,7 @@ export class ViewCommands implements Disposable {
if (!(node instanceof BranchNode)) return;
if (node.branch.remote) {
this.sendTerminalCommand('push', `${node.branch.getRemote()} :${node.branch.getName()}`, node.repoPath);
this.sendTerminalCommand('push', `${node.branch.getRemoteName()} :${node.branch.getName()}`, node.repoPath);
}
else {
this.sendTerminalCommand('branch', `-d ${node.ref}`, node.repoPath);
@ -679,7 +679,7 @@ export class ViewCommands implements Disposable {
const branch = node.branch || (await Container.git.getBranch(node.repoPath));
if (branch === undefined) return;
this.sendTerminalCommand('push', `${branch.getRemote()} ${node.ref}:${branch.getName()}`, node.repoPath);
this.sendTerminalCommand('push', `${branch.getRemoteName()} ${node.ref}:${branch.getName()}`, node.repoPath);
}
terminalRebaseCommit(node: CommitNode) {

Loading…
Cancel
Save