ソースを参照

Removes "Comparing" from branch compare node

Changes upstream arrows
main
Eric Amodio 5年前
コミット
da7a95e8c1
7個のファイルの変更81行の追加23行の削除
  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 ファイルの表示

@ -31,7 +31,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
if (isCommandViewContextWithBranch(context)) { if (isCommandViewContextWithBranch(context)) {
args = { ...args }; args = { ...args };
args.branch = context.node.branch.name; 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); return this.execute(context.editor, context.uri, args);

+ 13
- 2
src/git/models/branch.ts ファイルの表示

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { StarredBranches, WorkspaceState } from '../../constants'; import { StarredBranches, WorkspaceState } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { Git } from '../git';
import { Git, GitRemote } from '../git';
import { GitStatus } from './status'; import { GitStatus } from './status';
import { memoize } from '../../system'; import { memoize } from '../../system';
@ -58,7 +58,18 @@ export class GitBranch {
} }
@memoize() @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.remote) return GitBranch.getRemote(this.name);
if (this.tracking !== undefined) return GitBranch.getRemote(this.tracking); if (this.tracking !== undefined) return GitBranch.getRemote(this.tracking);

+ 1
- 1
src/quickpicks/repoStatusQuickPick.ts ファイルの表示

@ -434,7 +434,7 @@ export class RepoStatusQuickPick {
const pick = await window.showQuickPick(items, { const pick = await window.showQuickPick(items, {
matchOnDescription: true, matchOnDescription: true,
placeHolder: `status of ${status.branch}${ 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(), ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => { onDidSelectItem: (item: QuickPickItem) => {

+ 35
- 5
src/views/nodes/branchNode.ts ファイルの表示

@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ViewBranchesLayout } from '../../configuration'; import { ViewBranchesLayout } from '../../configuration';
import { GlyphChars } from '../../constants'; import { GlyphChars } from '../../constants';
import { Container } from '../../container'; 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 { debug, gate, Iterables, log } from '../../system';
import { RepositoriesView } from '../repositoriesView'; import { RepositoriesView } from '../repositoriesView';
import { BranchTrackingStatusNode } from './branchTrackingStatusNode'; import { BranchTrackingStatusNode } from './branchTrackingStatusNode';
@ -104,7 +104,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
return this._children; return this._children;
} }
getTreeItem(): TreeItem {
async getTreeItem(): Promise<TreeItem> {
const name = this.label; const name = this.label;
let tooltip = `${this.branch.getName()}${this.current ? ' (current)' : ''}`; let tooltip = `${this.branch.getName()}${this.current ? ' (current)' : ''}`;
let iconSuffix = ''; let iconSuffix = '';
@ -112,9 +112,39 @@ export class BranchNode extends ViewRefNode implements Pageabl
let description; let description;
if (!this.branch.remote && this.branch.tracking !== undefined) { if (!this.branch.remote && this.branch.tracking !== undefined) {
if (this.view.config.showTrackingBranch) { 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({ tooltip += ` is tracking ${this.branch.tracking}\n${this.branch.getTrackingStatus({
empty: 'up-to-date', empty: 'up-to-date',

+ 6
- 1
src/views/nodes/compareBranchNode.ts ファイルの表示

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

+ 23
- 11
src/views/nodes/remoteNode.ts ファイルの表示

@ -70,28 +70,40 @@ export class RemoteNode extends ViewNode {
} }
getTreeItem(): TreeItem { 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 { else {
separator = GlyphChars.Dash;
arrows = GlyphChars.Dash;
} }
const item = new TreeItem( const item = new TreeItem(
`${this.remote.default ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${this.remote.name}`, `${this.remote.default ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${this.remote.name}`,
TreeItemCollapsibleState.Collapsed TreeItemCollapsibleState.Collapsed
); );
item.description = `${separator}${GlyphChars.Space} ${
item.description = `${arrows}${GlyphChars.Space} ${
this.remote.provider !== undefined ? this.remote.provider.name : this.remote.domain this.remote.provider !== undefined ? this.remote.provider.name : this.remote.domain
} ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} ${ } ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} ${
this.remote.provider !== undefined ? this.remote.provider.displayPath : this.remote.path this.remote.provider !== undefined ? this.remote.provider.displayPath : this.remote.path

+ 2
- 2
src/views/viewCommands.ts ファイルの表示

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

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