Skip to content

Commit b474062

Browse files
committed
Adds actions in PausedOperationStatusNode
1 parent cf87e61 commit b474062

File tree

5 files changed

+155
-12
lines changed

5 files changed

+155
-12
lines changed

contributions.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4717,6 +4717,19 @@
47174717
"label": "Toggle Zen Mode",
47184718
"commandPalette": "gitlens:enabled"
47194719
},
4720+
"gitlens.views.abortPausedOperation": {
4721+
"label": "Abort",
4722+
"icon": "$(circle-slash)",
4723+
"menus": {
4724+
"view/item/context": [
4725+
{
4726+
"when": "viewItem =~ /gitlens:paused-operation\\b/ && !listMultiSelection",
4727+
"group": "inline",
4728+
"order": 3
4729+
}
4730+
]
4731+
}
4732+
},
47204733
"gitlens.views.addAuthor": {
47214734
"label": "Add as Co-author",
47224735
"icon": "$(person-add)",
@@ -5846,6 +5859,19 @@
58465859
]
58475860
}
58485861
},
5862+
"gitlens.views.continuePausedOperation": {
5863+
"label": "Continue",
5864+
"icon": "$(debug-continue)",
5865+
"menus": {
5866+
"view/item/context": [
5867+
{
5868+
"when": "viewItem =~ /gitlens:paused-operation:(cherry-pick|merge|rebase)\\b/ && !listMultiSelection",
5869+
"group": "inline",
5870+
"order": 1
5871+
}
5872+
]
5873+
}
5874+
},
58495875
"gitlens.views.contributors.copy": {
58505876
"label": "Copy",
58515877
"keybindings": [
@@ -7638,6 +7664,19 @@
76387664
]
76397665
}
76407666
},
7667+
"gitlens.views.openPausedOperationInRebaseEditor": {
7668+
"label": "Open in Rebase Editor",
7669+
"icon": "$(edit)",
7670+
"menus": {
7671+
"view/item/context": [
7672+
{
7673+
"when": "viewItem =~ /gitlens:paused-operation:rebase\\b/ && !listMultiSelection",
7674+
"group": "inline",
7675+
"order": 4
7676+
}
7677+
]
7678+
}
7679+
},
76417680
"gitlens.views.openPreviousChangesWithWorking": {
76427681
"label": "Open Previous Changes with Working File",
76437682
"menus": {
@@ -10391,6 +10430,19 @@
1039110430
]
1039210431
}
1039310432
},
10433+
"gitlens.views.skipPausedOperation": {
10434+
"label": "Skip",
10435+
"icon": "$(debug-step-over)",
10436+
"menus": {
10437+
"view/item/context": [
10438+
{
10439+
"when": "viewItem =~ /gitlens:paused-operation:(cherry-pick|rebase|revert)\\b/ && !listMultiSelection",
10440+
"group": "inline",
10441+
"order": 2
10442+
}
10443+
]
10444+
}
10445+
},
1039410446
"gitlens.views.stageDirectory": {
1039510447
"label": "Stage All Changes",
1039610448
"icon": "$(add)",

package.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7581,6 +7581,11 @@
75817581
"title": "Toggle Zen Mode",
75827582
"category": "GitLens"
75837583
},
7584+
{
7585+
"command": "gitlens.views.abortPausedOperation",
7586+
"title": "Abort",
7587+
"icon": "$(circle-slash)"
7588+
},
75847589
{
75857590
"command": "gitlens.views.addAuthor",
75867591
"title": "Add as Co-author",
@@ -7857,6 +7862,11 @@
78577862
"title": "Compare Working Tree to Here",
78587863
"icon": "$(gitlens-compare-ref-working)"
78597864
},
7865+
{
7866+
"command": "gitlens.views.continuePausedOperation",
7867+
"title": "Continue",
7868+
"icon": "$(debug-continue)"
7869+
},
78607870
{
78617871
"command": "gitlens.views.contributors.copy",
78627872
"title": "Copy"
@@ -8389,6 +8399,11 @@
83898399
"command": "gitlens.views.openOnlyChangedFiles",
83908400
"title": "Open Changed & Close Unchanged Files"
83918401
},
8402+
{
8403+
"command": "gitlens.views.openPausedOperationInRebaseEditor",
8404+
"title": "Open in Rebase Editor",
8405+
"icon": "$(edit)"
8406+
},
83928407
{
83938408
"command": "gitlens.views.openPreviousChangesWithWorking",
83948409
"title": "Open Previous Changes with Working File"
@@ -9116,6 +9131,11 @@
91169131
"command": "gitlens.views.setShowRelativeDateMarkersOn",
91179132
"title": "Show Date Markers"
91189133
},
9134+
{
9135+
"command": "gitlens.views.skipPausedOperation",
9136+
"title": "Skip",
9137+
"icon": "$(debug-step-over)"
9138+
},
91199139
{
91209140
"command": "gitlens.views.stageDirectory",
91219141
"title": "Stage All Changes",
@@ -11265,6 +11285,10 @@
1126511285
"command": "gitlens.toggleZenMode",
1126611286
"when": "gitlens:enabled"
1126711287
},
11288+
{
11289+
"command": "gitlens.views.abortPausedOperation",
11290+
"when": "false"
11291+
},
1126811292
{
1126911293
"command": "gitlens.views.addAuthor",
1127011294
"when": "false"
@@ -11509,6 +11533,10 @@
1150911533
"command": "gitlens.views.compareWithWorking",
1151011534
"when": "false"
1151111535
},
11536+
{
11537+
"command": "gitlens.views.continuePausedOperation",
11538+
"when": "false"
11539+
},
1151211540
{
1151311541
"command": "gitlens.views.contributors.copy",
1151411542
"when": "false"
@@ -11957,6 +11985,10 @@
1195711985
"command": "gitlens.views.openOnlyChangedFiles",
1195811986
"when": "false"
1195911987
},
11988+
{
11989+
"command": "gitlens.views.openPausedOperationInRebaseEditor",
11990+
"when": "false"
11991+
},
1196011992
{
1196111993
"command": "gitlens.views.openPreviousChangesWithWorking",
1196211994
"when": "false"
@@ -12569,6 +12601,10 @@
1256912601
"command": "gitlens.views.setShowRelativeDateMarkersOn",
1257012602
"when": "false"
1257112603
},
12604+
{
12605+
"command": "gitlens.views.skipPausedOperation",
12606+
"when": "false"
12607+
},
1257212608
{
1257312609
"command": "gitlens.views.stageDirectory",
1257412610
"when": "false"
@@ -16198,6 +16234,26 @@
1619816234
"when": "viewItem =~ /gitlens:pager\\b/ && !listMultiSelection",
1619916235
"group": "1_gitlens_actions@1"
1620016236
},
16237+
{
16238+
"command": "gitlens.views.abortPausedOperation",
16239+
"when": "viewItem =~ /gitlens:paused-operation\\b/ && !listMultiSelection",
16240+
"group": "inline@3"
16241+
},
16242+
{
16243+
"command": "gitlens.views.continuePausedOperation",
16244+
"when": "viewItem =~ /gitlens:paused-operation:(cherry-pick|merge|rebase)\\b/ && !listMultiSelection",
16245+
"group": "inline@1"
16246+
},
16247+
{
16248+
"command": "gitlens.views.skipPausedOperation",
16249+
"when": "viewItem =~ /gitlens:paused-operation:(cherry-pick|rebase|revert)\\b/ && !listMultiSelection",
16250+
"group": "inline@2"
16251+
},
16252+
{
16253+
"command": "gitlens.views.openPausedOperationInRebaseEditor",
16254+
"when": "viewItem =~ /gitlens:paused-operation:rebase\\b/ && !listMultiSelection",
16255+
"group": "inline@4"
16256+
},
1620116257
{
1620216258
"command": "gitlens.views.openPullRequest",
1620316259
"when": "viewItem =~ /gitlens:pullrequest\\b/ && gitlens:action:openPullRequest > 1",

src/constants.commands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,11 @@ export type TreeViewCommands = `gitlens.views.${
665665
| 'setResultsCommitsFilterAuthors'
666666
| 'setResultsCommitsFilterOff'
667667
| 'setContributorsStatisticsOff'
668-
| 'setContributorsStatisticsOn'}`;
668+
| 'setContributorsStatisticsOn'
669+
| 'abortPausedOperation'
670+
| 'continuePausedOperation'
671+
| 'skipPausedOperation'
672+
| 'openPausedOperationInRebaseEditor'}`;
669673

670674
type ExtractSuffix<Prefix extends string, U> = U extends `${Prefix}${infer V}` ? V : never;
671675
type FilterCommands<Prefix extends string, U> = U extends `${Prefix}${infer V}` ? `${Prefix}${V}` : never;

src/views/nodes/pausedOperationStatusNode.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
1+
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
22
import type { Colors } from '../../constants.colors';
33
import { GitUri } from '../../git/gitUri';
44
import type { GitBranch } from '../../git/models/branch';
@@ -7,7 +7,6 @@ import { getReferenceLabel } from '../../git/models/reference.utils';
77
import type { GitStatus } from '../../git/models/status';
88
import { pausedOperationStatusStringsByType } from '../../git/utils/pausedOperationStatus.utils';
99
import { pluralize } from '../../system/string';
10-
import { executeCoreCommand } from '../../system/vscode/command';
1110
import type { ViewsWithCommits } from '../viewBase';
1211
import { createViewDecorationUri } from '../viewDecorationProvider';
1312
import { ContextValues, getViewNodeId, ViewNode } from './abstract/viewNode';
@@ -172,13 +171,4 @@ export class PausedOperationStatusNode extends ViewNode<'paused-operation-status
172171
markdown.isTrusted = true;
173172
return markdown;
174173
}
175-
176-
async openRebaseEditor() {
177-
if (this.pausedOpStatus.type !== 'rebase') return;
178-
179-
const rebaseTodoUri = Uri.joinPath(this.uri, '.git', 'rebase-merge', 'git-rebase-todo');
180-
await executeCoreCommand('vscode.openWith', rebaseTodoUri, 'gitlens.rebase', {
181-
preview: false,
182-
});
183-
}
184174
}

src/views/viewCommands.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import type { FileRevisionAsCommitNode } from './nodes/fileRevisionAsCommitNode'
8181
import type { FolderNode } from './nodes/folderNode';
8282
import type { LineHistoryNode } from './nodes/lineHistoryNode';
8383
import type { MergeConflictFileNode } from './nodes/mergeConflictFileNode';
84+
import type { PausedOperationStatusNode } from './nodes/pausedOperationStatusNode';
8485
import type { PullRequestNode } from './nodes/pullRequestNode';
8586
import type { RemoteNode } from './nodes/remoteNode';
8687
import type { RepositoryNode } from './nodes/repositoryNode';
@@ -403,6 +404,15 @@ export class ViewCommands implements Disposable {
403404
true,
404405
),
405406

407+
registerViewCommand('gitlens.views.abortPausedOperation', this.abortPausedOperation, this),
408+
registerViewCommand('gitlens.views.continuePausedOperation', this.continuePausedOperation, this),
409+
registerViewCommand('gitlens.views.skipPausedOperation', this.skipPausedOperation, this),
410+
registerViewCommand(
411+
'gitlens.views.openPausedOperationInRebaseEditor',
412+
this.openPausedOperationInRebaseEditor,
413+
this,
414+
),
415+
406416
registerViewCommand(
407417
'gitlens.views.setResultsCommitsFilterAuthors',
408418
n => this.setResultsCommitsFilter(n, true),
@@ -704,6 +714,37 @@ export class ViewCommands implements Disposable {
704714
return executeCoreCommand('openInIntegratedTerminal', Uri.file(node.repoPath));
705715
}
706716

717+
@log()
718+
private abortPausedOperation(node: PausedOperationStatusNode) {
719+
if (!node.is('paused-operation-status')) return Promise.resolve();
720+
721+
return this.container.git.status(node.pausedOpStatus.repoPath).abortPausedOperation?.();
722+
}
723+
724+
@log()
725+
private continuePausedOperation(node: PausedOperationStatusNode) {
726+
if (!node.is('paused-operation-status')) return Promise.resolve();
727+
728+
return this.container.git.status(node.pausedOpStatus.repoPath).continuePausedOperation?.();
729+
}
730+
731+
@log()
732+
private skipPausedOperation(node: PausedOperationStatusNode) {
733+
if (!node.is('paused-operation-status')) return Promise.resolve();
734+
735+
return this.container.git.status(node.pausedOpStatus.repoPath).continuePausedOperation?.({ skip: true });
736+
}
737+
738+
@log()
739+
private openPausedOperationInRebaseEditor(node: PausedOperationStatusNode) {
740+
if (!node.is('paused-operation-status') || node.pausedOpStatus.type !== 'rebase') return Promise.resolve();
741+
742+
const rebaseTodoUri = Uri.joinPath(node.uri, '.git', 'rebase-merge', 'git-rebase-todo');
743+
return executeCoreCommand('vscode.openWith', rebaseTodoUri, 'gitlens.rebase', {
744+
preview: false,
745+
});
746+
}
747+
707748
@log()
708749
private openPullRequest(node: PullRequestNode) {
709750
if (!node.is('pullrequest')) return Promise.resolve();

0 commit comments

Comments
 (0)