Skip to content

Commit adda808

Browse files
committed
Moves filter into getRemotes
1 parent 35b437a commit adda808

File tree

10 files changed

+16
-12
lines changed

10 files changed

+16
-12
lines changed

src/commands/openBranchInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
5252
if (args.branch === undefined) return undefined;
5353
}
5454

55-
const remotes = (await Container.git.getRemotes(repoPath)).filter(r => r.provider !== undefined);
55+
const remotes = await Container.git.getRemotes(repoPath);
5656

5757
return commands.executeCommand(Commands.OpenInRemote, uri, {
5858
resource: {

src/commands/openBranchesInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
3434
if (!repoPath) return undefined;
3535

3636
try {
37-
const remotes = (await Container.git.getRemotes(repoPath)).filter(r => r.provider !== undefined);
37+
const remotes = await Container.git.getRemotes(repoPath);
3838

3939
return commands.executeCommand(Commands.OpenInRemote, uri, {
4040
resource: {

src/commands/openCommitInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
6666
args.sha = commit.sha;
6767
}
6868

69-
const remotes = (await Container.git.getRemotes(gitUri.repoPath)).filter(r => r.provider !== undefined);
69+
const remotes = await Container.git.getRemotes(gitUri.repoPath);
7070

7171
return commands.executeCommand(Commands.OpenInRemote, uri, {
7272
resource: {

src/commands/openFileInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
4545
}
4646

4747
try {
48-
const remotes = (await Container.git.getRemotes(gitUri.repoPath)).filter(r => r.provider !== undefined);
48+
const remotes = await Container.git.getRemotes(gitUri.repoPath);
4949
const range = (args.range && editor !== undefined)
5050
? new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }))
5151
: undefined;

src/commands/openRepoInRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
3434
if (!repoPath) return undefined;
3535

3636
try {
37-
const remotes = (await Container.git.getRemotes(repoPath)).filter(r => r.provider !== undefined);
37+
const remotes = await Container.git.getRemotes(repoPath);
3838

3939
return commands.executeCommand(Commands.OpenInRemote, uri, {
4040
resource: {

src/gitService.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,15 +1073,19 @@ export class GitService extends Disposable {
10731073
}
10741074
}
10751075

1076-
async getRemotes(repoPath: string | undefined): Promise<GitRemote[]> {
1076+
async getRemotes(repoPath: string | undefined, options: { includeAll?: boolean } = {}): Promise<GitRemote[]> {
10771077
if (repoPath === undefined) return [];
10781078

10791079
Logger.log(`getRemotes('${repoPath}')`);
10801080

10811081
const repository = await this.getRepository(repoPath);
1082-
if (repository !== undefined) return repository.getRemotes();
1082+
const remotes = repository !== undefined
1083+
? repository.getRemotes()
1084+
: this.getRemotesCore(repoPath);
10831085

1084-
return this.getRemotesCore(repoPath);
1086+
if (options.includeAll) return remotes;
1087+
1088+
return (await remotes).filter(r => r.provider !== undefined);
10851089
}
10861090

10871091
async getRemotesCore(repoPath: string | undefined, providerMap?: RemoteProviderMap): Promise<GitRemote[]> {

src/quickPicks/branchHistoryQuickPick.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class BranchHistoryQuickPick {
3636
} as ShowQuickBranchHistoryCommandArgs
3737
]);
3838

39-
const remotes = (await Container.git.getRemotes((uri && uri.repoPath) || log.repoPath)).filter(r => r.provider !== undefined);
39+
const remotes = await Container.git.getRemotes((uri && uri.repoPath) || log.repoPath);
4040
if (remotes.length) {
4141
items.splice(0, 0, new OpenRemotesCommandQuickPickItem(remotes, {
4242
type: 'branch',

src/quickPicks/commitFileQuickPick.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class CommitFileQuickPick {
120120
}
121121
items.push(new OpenCommitFileRevisionCommandQuickPickItem(commit));
122122

123-
const remotes = (await Container.git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
123+
const remotes = await Container.git.getRemotes(commit.repoPath);
124124
if (remotes.length) {
125125
if (commit.workingFileName && commit.status !== 'D') {
126126
const branch = await Container.git.getBranch(commit.repoPath);

src/quickPicks/commitQuickPick.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class CommitQuickPick {
129129
else {
130130
items.splice(index++, 0, new ShowCommitInResultsQuickPickItem(commit));
131131

132-
const remotes = (await Container.git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
132+
const remotes = await Container.git.getRemotes(commit.repoPath);
133133
if (remotes.length) {
134134
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
135135
type: 'commit',

src/quickPicks/fileHistoryQuickPick.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class FileHistoryQuickPick {
110110
]));
111111
}
112112

113-
const remotes = (await Container.git.getRemotes(uri.repoPath!)).filter(r => r.provider !== undefined);
113+
const remotes = await Container.git.getRemotes(uri.repoPath!);
114114
if (remotes.length) {
115115
const resource = uri.sha !== undefined
116116
? {

0 commit comments

Comments
 (0)