Skip to content

Commit 1772745

Browse files
committed
Changes graph sync to force push
1 parent 76222ff commit 1772745

File tree

3 files changed

+29
-56
lines changed

3 files changed

+29
-56
lines changed

package.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8826,10 +8826,10 @@
88268826
"enablement": "!operationInProgress"
88278827
},
88288828
{
8829-
"command": "gitlens.graph.sync",
8830-
"title": "Pull",
8829+
"command": "gitlens.graph.pushWithForce",
8830+
"title": "Push (force)",
88318831
"category": "GitLens",
8832-
"icon": "$(gitlens-repo-sync)",
8832+
"icon": "$(gitlens-repo-force-push)",
88338833
"enablement": "!operationInProgress"
88348834
},
88358835
{
@@ -12003,7 +12003,7 @@
1200312003
"when": "false"
1200412004
},
1200512005
{
12006-
"command": "gitlens.graph.sync",
12006+
"command": "gitlens.graph.pushWithForce",
1200712007
"when": "false"
1200812008
},
1200912009
{
@@ -15588,11 +15588,6 @@
1558815588
"when": "gitlens:repos:withRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(behind|tracking)\\b)(?!.*?\\b\\+closed\\b)/",
1558915589
"group": "1_gitlens_actions@2"
1559015590
},
15591-
{
15592-
"command": "gitlens.graph.sync",
15593-
"when": "false",
15594-
"group": "1_gitlens_actions@2"
15595-
},
1559615591
{
1559715592
"command": "gitlens.graph.fetch",
1559815593
"when": "gitlens:repos:withRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(remote|tracking)\\b)(?!.*?\\b\\+closed\\b)/",
@@ -15848,11 +15843,6 @@
1584815843
"when": "webviewItem =~ /gitlens:upstreamStatus\\b/",
1584915844
"group": "1_gitlens_actions@2"
1585015845
},
15851-
{
15852-
"command": "gitlens.graph.sync",
15853-
"when": "sync",
15854-
"group": "1_gitlens_actions@2"
15855-
},
1585615846
{
1585715847
"command": "gitlens.graph.fetch",
1585815848
"when": "webviewItem =~ /gitlens:upstreamStatus\\b/",

src/plus/webviews/graph/graphWebview.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
447447
this.host.registerWebviewCommand('gitlens.graph.push', this.push),
448448
this.host.registerWebviewCommand('gitlens.graph.pull', this.pull),
449449
this.host.registerWebviewCommand('gitlens.graph.fetch', this.fetch),
450-
this.host.registerWebviewCommand('gitlens.graph.sync', this.sync),
450+
this.host.registerWebviewCommand('gitlens.graph.pushWithForce', this.forcePush),
451451
this.host.registerWebviewCommand('gitlens.graph.publishBranch', this.publishBranch),
452452
this.host.registerWebviewCommand('gitlens.graph.switchToAnotherBranch', this.switchToAnother),
453453

@@ -2856,13 +2856,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
28562856
void RepoActions.fetch(this.repository, ref);
28572857
}
28582858

2859-
// @unimplemented
28602859
@log()
2861-
private sync(item?: GraphItemContext) {
2862-
throw new Error('unimplemented');
2863-
// const ref = item != null ? this.getGraphItemRef(item, 'branch') : undefined;
2864-
// await RepoActions.pull(this.repository, ref);
2865-
// void RepoActions.push(this.repository, undefined, ref);
2860+
private forcePush(item?: GraphItemContext) {
2861+
this.push(item, true);
28662862
}
28672863

28682864
@log()
@@ -2872,9 +2868,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
28722868
}
28732869

28742870
@log()
2875-
private push(item?: GraphItemContext) {
2871+
private push(item?: GraphItemContext, force?: boolean) {
28762872
const ref = item != null ? this.getGraphItemRef(item) : undefined;
2877-
void RepoActions.push(this.repository, undefined, ref);
2873+
void RepoActions.push(this.repository, force, ref);
28782874
}
28792875

28802876
@log()

src/webviews/apps/plus/graph/actions/syncButton.tsx

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React from 'react';
33
import type { BranchState, State } from '../../../../../plus/webviews/graph/protocol';
44
import { pluralize } from '../../../../../system/string';
55
import { createWebviewCommandLink } from '../../../../../system/webview';
6-
import { MenuItem, MenuLabel, MenuList } from '../../../shared/components/menu/react';
7-
import { PopMenu } from '../../../shared/components/overlays/pop-menu/react';
6+
import { MenuItem, MenuLabel } from '../../../shared/components/menu/react';
7+
import { GlPopover } from '../../../shared/components/overlays/popover.react';
88
import { GlTooltip } from '../../../shared/components/overlays/tooltip.react';
99

1010
export const SyncButton = ({
@@ -119,42 +119,29 @@ export const SyncButton = ({
119119
</div>
120120
</GlTooltip>
121121
{isAhead && isBehind && (
122-
<GlTooltip placement="top" distance={7}>
123-
<PopMenu position="right">
124-
<button type="button" className="action-button" slot="trigger" aria-label="Minimap Options">
122+
<GlPopover className="popover" placement="bottom-start" trigger="focus" arrow={false} distance={0}>
123+
<GlTooltip placement="top" slot="anchor">
124+
<button type="button" className="action-button" aria-label="Branch Actions">
125125
<span
126126
className="codicon codicon-chevron-down action-button__more"
127127
aria-hidden="true"
128128
></span>
129129
</button>
130-
<MenuList slot="content" style={{ width: 120 }}>
131-
<MenuLabel>Git actions</MenuLabel>
132-
<MenuItem>
133-
<a
134-
href={createWebviewCommandLink(
135-
'gitlens.graph.pull',
136-
state.webviewId,
137-
state.webviewInstanceId,
138-
)}
139-
>
140-
Pull...
141-
</a>
142-
</MenuItem>
143-
<MenuItem>
144-
<a
145-
href={createWebviewCommandLink(
146-
'gitlens.graph.push',
147-
state.webviewId,
148-
state.webviewInstanceId,
149-
)}
150-
>
151-
Push...
152-
</a>
153-
</MenuItem>
154-
</MenuList>
155-
</PopMenu>
156-
<span slot="content">Git Sync Options</span>
157-
</GlTooltip>
130+
<span slot="content">Branch Actions</span>
131+
</GlTooltip>
132+
<div slot="content">
133+
<MenuLabel>Branch actions</MenuLabel>
134+
<MenuItem
135+
href={createWebviewCommandLink(
136+
'gitlens.graph.pushWithForce',
137+
state.webviewId,
138+
state.webviewInstanceId,
139+
)}
140+
>
141+
Push (force)
142+
</MenuItem>
143+
</div>
144+
</GlPopover>
158145
)}
159146
</span>
160147
);

0 commit comments

Comments
 (0)