Selaa lähdekoodia

Adds pull/push to current branch if available

main
Eric Amodio 5 vuotta sitten
vanhempi
commit
202405d697
4 muutettua tiedostoa jossa 79 lisäystä ja 58 poistoa
  1. +46
    -35
      package.json
  2. +17
    -14
      src/views/nodes/branchNode.ts
  3. +8
    -4
      src/views/nodes/repositoryNode.ts
  4. +8
    -5
      src/views/viewCommands.ts

+ 46
- 35
package.json Näytä tiedosto

@ -4508,6 +4508,17 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.push",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+ahead\\b)/",
"group": "inline@8",
"alt": "gitlens.views.pushWithForce"
},
{
"command": "gitlens.views.pull",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+behind\\b)/",
"group": "inline@9"
},
{
"command": "gitlens.views.switchToBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b/",
"group": "inline@10"
@ -4606,32 +4617,32 @@
{
"command": "gitlens.views.openDirectoryDiffWithWorking",
"when": "viewItem =~ /gitlens:(branch|tag)\\b/",
"group": "7_gitlens_more@2"
"group": "7_gitlens_1@2"
},
{
"command": "gitlens.views.terminalCreateBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:(branch|commit|tag)\\b/",
"group": "8_gitlens@5"
"group": "8_gitlens_terminal@5"
},
{
"command": "gitlens.views.terminalDeleteBranch",
"when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/",
"group": "8_gitlens@6"
"group": "8_gitlens_terminal@6"
},
{
"command": "gitlens.views.terminalCreateTag",
"when": "!gitlens:readonly && viewItem =~ /gitlens:(branch|commit)\\b/",
"group": "8_gitlens@7"
"group": "8_gitlens_terminal@7"
},
{
"command": "gitlens.views.star",
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+starred\\b)/",
"group": "8_gitlens_@1"
"group": "8_gitlens_98@1"
},
{
"command": "gitlens.views.unstar",
"when": "viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+starred\\b)/",
"group": "8_gitlens_@1"
"group": "8_gitlens_98@1"
},
{
"command": "gitlens.inviteToLiveShare",
@ -4742,7 +4753,7 @@
{
"command": "gitlens.views.terminalPushCommit",
"when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/",
"group": "8_gitlens@2"
"group": "8_gitlens_terminal@2"
},
{
"command": "gitlens.views.openFile",
@ -4920,42 +4931,42 @@
{
"command": "gitlens.views.terminalRemoveRemote",
"when": "!gitlens:readonly && viewItem =~ /gitlens:remote\\b/",
"group": "8_gitlens@1"
"group": "8_gitlens_terminal@1"
},
{
"command": "gitlens.views.setAsDefault",
"when": "viewItem =~ /gitlens:remote\\b(?!.*?\\b\\+default\\b)/",
"group": "8_gitlens_@1"
"group": "8_gitlens_98@1"
},
{
"command": "gitlens.views.unsetAsDefault",
"when": "viewItem =~ /gitlens:remote\\b(?=.*?\\b\\+default\\b)/",
"group": "8_gitlens_@1"
"group": "8_gitlens_98@1"
},
{
"command": "gitlens.views.exploreRepoAtRevision",
"when": "viewItem =~ /gitlens:(branch|commit|file\\b((?=.*?\\b\\+committed\\b)|:results)|stash|tag)\\b/",
"group": "7_gitlens_more@1"
},
{
"command": "gitlens.showCommitSearch",
"when": "viewItem =~ /gitlens:repository\\b/",
"group": "inline@10"
"group": "7_gitlens_1@1"
},
{
"command": "gitlens.views.push",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/",
"group": "inline@96",
"group": "inline@95",
"alt": "gitlens.views.pushWithForce"
},
{
"command": "gitlens.views.pull",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/",
"group": "inline@97"
"group": "inline@96"
},
{
"command": "gitlens.views.fetch",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/",
"group": "inline@97"
},
{
"command": "gitlens.showCommitSearch",
"when": "viewItem =~ /gitlens:repository\\b/",
"group": "inline@98"
},
{
@ -5016,22 +5027,28 @@
{
"command": "gitlens.views.star",
"when": "viewItem =~ /gitlens:repository\\b(?!.*?\\b\\+starred\\b)/",
"group": "8_gitlens@1"
"group": "8_gitlens_98@1"
},
{
"command": "gitlens.views.unstar",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+starred\\b)/",
"group": "8_gitlens@1"
"group": "8_gitlens_98@1"
},
{
"command": "gitlens.views.closeRepository",
"when": "viewItem =~ /gitlens:repository\\b/",
"group": "8_gitlens@2"
"group": "8_gitlens_98@2"
},
{
"command": "gitlens.views.push",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:ahead",
"group": "inline@1",
"alt": "gitlens.views.pushWithForce"
},
{
"command": "gitlens.views.pull",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:behind",
"group": "inline@1"
"group": "inline@2"
},
{
"command": "gitlens.views.pull",
@ -5041,12 +5058,6 @@
{
"command": "gitlens.views.push",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:ahead",
"group": "inline@1",
"alt": "gitlens.views.pushWithForce"
},
{
"command": "gitlens.views.push",
"when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:ahead",
"group": "1_gitlens@1"
},
{
@ -5227,7 +5238,7 @@
{
"command": "gitlens.views.terminalDeleteTag",
"when": "!gitlens:readonly && viewItem == gitlens:tag",
"group": "8_gitlens"
"group": "8_gitlens_terminal"
},
{
"command": "gitlens.views.stageDirectory",
@ -5250,14 +5261,14 @@
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.expandNode",
"when": "viewItem =~ /gitlens:(compare|folder|results|search|status)\\b/",
"group": "8_gitlens@1"
},
{
"command": "gitlens.views.dismissNode",
"when": "viewItem =~ /gitlens:(compare:picker:ref|compare:results\\b(?!.*?\\b\\+pinned\\b)|search)\\b(?!:(commits|files))/",
"group": "8_gitlens@2"
"group": "8_gitlens_99@98"
},
{
"command": "gitlens.views.expandNode",
"when": "viewItem =~ /gitlens:(branch|compare|folder|results|search|status)\\b/",
"group": "8_gitlens_99@99"
},
{
"command": "gitlens.views.refreshNode",

+ 17
- 14
src/views/nodes/branchNode.ts Näytä tiedosto

@ -123,6 +123,20 @@ export class BranchNode extends ViewRefNode implements Pageabl
let tooltip = `${this.branch.getName()}${this.current ? ' (current)' : ''}`;
let iconSuffix = '';
let contextValue: string = ResourceType.Branch;
if (this.current) {
contextValue += '+current';
}
if (this.branch.remote) {
contextValue += '+remote';
}
if (this.branch.starred) {
contextValue += '+starred';
}
if (this.branch.tracking) {
contextValue += '+tracking';
}
let description;
if (!this.branch.remote && this.branch.tracking !== undefined) {
if (this.view.config.showTrackingBranch) {
@ -165,9 +179,11 @@ export class BranchNode extends ViewRefNode implements Pageabl
if (this.branch.state.ahead || this.branch.state.behind) {
if (this.branch.state.behind) {
contextValue += '+behind';
iconSuffix = '-red';
}
if (this.branch.state.ahead) {
contextValue += '+ahead';
iconSuffix = this.branch.state.behind ? '-yellow' : '-green';
}
}
@ -188,20 +204,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
`${!this.root && this.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`,
TreeItemCollapsibleState.Collapsed
);
item.contextValue = ResourceType.Branch;
if (this.current) {
item.contextValue += '+current';
}
if (this.branch.remote) {
item.contextValue += '+remote';
}
if (this.branch.starred) {
item.contextValue += '+starred';
}
if (this.branch.tracking) {
item.contextValue += '+tracking';
}
item.contextValue = contextValue;
item.description = description;
item.iconPath = {
dark: Container.context.asAbsolutePath(`images/dark/icon-branch${iconSuffix}.svg`),

+ 8
- 4
src/views/nodes/repositoryNode.ts Näytä tiedosto

@ -131,6 +131,11 @@ export class RepositoryNode extends SubscribeableViewNode {
let iconSuffix = '';
let workingStatus = '';
let contextValue: string = ResourceType.Repository;
if (this.repo.starred) {
contextValue += '+starred';
}
const status = await this._status;
if (status !== undefined) {
tooltip += `\n\nCurrent branch is ${status.branch}`;
@ -158,10 +163,12 @@ export class RepositoryNode extends SubscribeableViewNode {
})}`;
if (status.state.behind) {
contextValue += '+behind';
iconSuffix = '-red';
}
if (status.state.ahead) {
iconSuffix = status.state.behind ? '-yellow' : '-green';
contextValue += '+ahead';
}
}
@ -180,10 +187,7 @@ export class RepositoryNode extends SubscribeableViewNode {
}
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
item.contextValue = ResourceType.Repository;
if (this.repo.starred) {
item.contextValue += '+starred';
}
item.contextValue = contextValue;
item.description = `${description || ''}${this.formatLastFetched({
prefix: `${Strings.pad(GlyphChars.Dot, 2, 2)}Last fetched `
})}`;

+ 8
- 5
src/views/viewCommands.ts Näytä tiedosto

@ -317,8 +317,8 @@ export class ViewCommands {
}
@debug()
private pull(node: RepositoryNode | BranchTrackingStatusNode) {
if (node instanceof BranchTrackingStatusNode) {
private pull(node: RepositoryNode | BranchNode | BranchTrackingStatusNode) {
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
node = node.getParent() as RepositoryNode;
}
if (!(node instanceof RepositoryNode)) return undefined;
@ -328,13 +328,16 @@ export class ViewCommands {
}
@debug()
private push(node: RepositoryNode | BranchTrackingStatusNode, force?: boolean) {
if (node instanceof BranchTrackingStatusNode) {
private push(node: RepositoryNode | BranchNode | BranchTrackingStatusNode, force?: boolean) {
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
node = node.getParent() as RepositoryNode;
}
if (!(node instanceof RepositoryNode)) return undefined;
const args: GitCommandsCommandArgs = { command: 'push', state: { repos: [node.repo] } };
const args: GitCommandsCommandArgs = {
command: 'push',
state: { repos: [node.repo], flags: force ? ['--force'] : [] }
};
return commands.executeCommand(Commands.GitCommands, args);
}

Ladataan…
Peruuta
Tallenna