Skip to content

Commit e055299

Browse files
committed
fix git commands
1 parent 6df05c8 commit e055299

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

extensions/git/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@
11941194
{
11951195
"command": "git.openFile",
11961196
"group": "navigation",
1197-
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1197+
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
11981198
},
11991199
{
12001200
"command": "git.openChange",
@@ -1204,44 +1204,44 @@
12041204
{
12051205
"command": "git.stageSelectedRanges",
12061206
"group": "2_git@1",
1207-
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1207+
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
12081208
},
12091209
{
12101210
"command": "git.unstageSelectedRanges",
12111211
"group": "2_git@2",
1212-
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1212+
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
12131213
},
12141214
{
12151215
"command": "git.revertSelectedRanges",
12161216
"group": "2_git@3",
1217-
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1217+
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
12181218
}
12191219
],
12201220
"editor/context": [
12211221
{
12221222
"command": "git.stageSelectedRanges",
12231223
"group": "2_git@1",
1224-
"when": "isInDiffRightEditor && config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1224+
"when": "isInDiffRightEditor && config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
12251225
},
12261226
{
12271227
"command": "git.unstageSelectedRanges",
12281228
"group": "2_git@2",
1229-
"when": "isInDiffRightEditor && config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1229+
"when": "isInDiffRightEditor && config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
12301230
},
12311231
{
12321232
"command": "git.revertSelectedRanges",
12331233
"group": "2_git@3",
1234-
"when": "isInDiffRightEditor && config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^git$|^file$/"
1234+
"when": "isInDiffRightEditor && config.git.enabled && gitOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme =~ /^gitfs$|^file$/"
12351235
}
12361236
],
12371237
"scm/change/title": [
12381238
{
12391239
"command": "git.stageChange",
1240-
"when": "originalResourceScheme == git"
1240+
"when": "originalResourceScheme == gitfs"
12411241
},
12421242
{
12431243
"command": "git.revertChange",
1244-
"when": "originalResourceScheme == git"
1244+
"when": "originalResourceScheme == gitfs"
12451245
}
12461246
]
12471247
},

extensions/git/src/commands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { CommitOptions, ForcePushMode, Git, Stash } from './git';
1414
import { Model } from './model';
1515
import { Repository, Resource, ResourceGroupType } from './repository';
1616
import { applyLineChanges, getModifiedRange, intersectDiffWithRange, invertLineChange, toLineRanges } from './staging';
17-
import { fromGitUri, toGitUri } from './uri';
17+
import { fromGitUri, toGitUri, isGitUri } from './uri';
1818
import { grep, isDescendant, pathEquals } from './util';
1919

2020
const localize = nls.loadMessageBundle();
@@ -692,7 +692,7 @@ export class CommandCenter {
692692
let uris: Uri[] | undefined;
693693

694694
if (arg instanceof Uri) {
695-
if (arg.scheme === 'git') {
695+
if (isGitUri(arg)) {
696696
uris = [Uri.file(fromGitUri(arg).path)];
697697
} else if (arg.scheme === 'file') {
698698
uris = [arg];
@@ -1117,7 +1117,7 @@ export class CommandCenter {
11171117
const modifiedDocument = textEditor.document;
11181118
const modifiedUri = modifiedDocument.uri;
11191119

1120-
if (modifiedUri.scheme !== 'git') {
1120+
if (!isGitUri(modifiedUri)) {
11211121
return;
11221122
}
11231123

@@ -2454,7 +2454,7 @@ export class CommandCenter {
24542454
return undefined;
24552455
}
24562456

2457-
if (uri.scheme === 'git') {
2457+
if (isGitUri(uri)) {
24582458
const { path } = fromGitUri(uri);
24592459
uri = Uri.file(path);
24602460
}

extensions/git/src/uri.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export interface GitUriParams {
1111
submoduleOf?: string;
1212
}
1313

14+
export function isGitUri(uri: Uri): boolean {
15+
return /^git(fs)?$/.test(uri.scheme);
16+
}
17+
1418
export function fromGitUri(uri: Uri): GitUriParams {
1519
return JSON.parse(uri.query);
1620
}

0 commit comments

Comments
 (0)