Skip to content

Commit a116774

Browse files
committed
Adds Copy Changes (Patch) to branch comparisons
Adds Copy Changes (Patch) to comparisons files
1 parent 2183dac commit a116774

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15376,7 +15376,7 @@
1537615376
},
1537715377
{
1537815378
"command": "gitlens.copyPatchToClipboard",
15379-
"when": "!listMultiSelection && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/",
15379+
"when": "!listMultiSelection && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file(\\b(?=.*?\\b\\+committed\\b)|:results)/",
1538015380
"group": "7_gitlens_cutcopypaste@3"
1538115381
},
1538215382
{
@@ -16249,7 +16249,7 @@
1624916249
},
1625016250
{
1625116251
"command": "gitlens.copyPatchToClipboard",
16252-
"when": "!listMultiSelection && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:compare:results(?!:)\\b/",
16252+
"when": "!listMultiSelection && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:compare:(branch|results(?!:))\\b/",
1625316253
"group": "7_gitlens_cutcopypaste@97"
1625416254
},
1625516255
{

src/commands/patches.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
isCommandContextViewNodeHasCommit,
3030
isCommandContextViewNodeHasComparison,
3131
isCommandContextViewNodeHasFileCommit,
32+
isCommandContextViewNodeHasFileRefs,
3233
} from './base';
3334

3435
export interface CreatePatchCommandArgs {
@@ -122,6 +123,13 @@ abstract class CreatePatchCommandBase extends Command {
122123
context.node.compareWithRef.ref,
123124
)}`,
124125
};
126+
} else if (isCommandContextViewNodeHasFileRefs(context)) {
127+
args = {
128+
repoPath: context.node.repoPath,
129+
to: context.node.ref2,
130+
from: context.node.ref1,
131+
uris: [context.node.uri],
132+
};
125133
}
126134
}
127135
}

src/views/nodes/compareBranchNode.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Disposable, TreeCheckboxChangeEvent } from 'vscode';
22
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
33
import type { ViewShowBranchComparison } from '../../config';
44
import { GlyphChars } from '../../constants';
5-
import type { StoredBranchComparison, StoredBranchComparisons } from '../../constants.storage';
5+
import type { StoredBranchComparison, StoredBranchComparisons, StoredNamedRef } from '../../constants.storage';
66
import type { GitUri } from '../../git/gitUri';
77
import type { GitBranch } from '../../git/models/branch';
88
import { createRevisionRange, shortenRevision } from '../../git/models/reference';
@@ -73,11 +73,19 @@ export class CompareBranchNode extends SubscribeableViewNode<
7373
};
7474
}
7575

76+
get compareRef(): StoredNamedRef {
77+
return { label: this.branch.name, ref: this.branch.sha! };
78+
}
79+
7680
private _compareWith: StoredBranchComparison | undefined;
7781
get compareWith(): StoredBranchComparison | undefined {
7882
return this._compareWith;
7983
}
8084

85+
get compareWithRef(): StoredNamedRef | undefined {
86+
return this._compareWith != null ? { label: this._compareWith.label, ref: this._compareWith.ref } : undefined;
87+
}
88+
8189
private _isFiltered: boolean | undefined;
8290
private get filterByAuthors(): GitUser[] | undefined {
8391
const authors = this.getState('filterCommits');

0 commit comments

Comments
 (0)