Browse Source

Moves filter into getRemotes

main
Eric Amodio 6 years ago
parent
commit
adda808182
10 changed files with 16 additions and 12 deletions
  1. +1
    -1
      src/commands/openBranchInRemote.ts
  2. +1
    -1
      src/commands/openBranchesInRemote.ts
  3. +1
    -1
      src/commands/openCommitInRemote.ts
  4. +1
    -1
      src/commands/openFileInRemote.ts
  5. +1
    -1
      src/commands/openRepoInRemote.ts
  6. +7
    -3
      src/gitService.ts
  7. +1
    -1
      src/quickPicks/branchHistoryQuickPick.ts
  8. +1
    -1
      src/quickPicks/commitFileQuickPick.ts
  9. +1
    -1
      src/quickPicks/commitQuickPick.ts
  10. +1
    -1
      src/quickPicks/fileHistoryQuickPick.ts

+ 1
- 1
src/commands/openBranchInRemote.ts View File

@ -52,7 +52,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
if (args.branch === undefined) return undefined;
}
const remotes = (await Container.git.getRemotes(repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(repoPath);
return commands.executeCommand(Commands.OpenInRemote, uri, {
resource: {

+ 1
- 1
src/commands/openBranchesInRemote.ts View File

@ -34,7 +34,7 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
if (!repoPath) return undefined;
try {
const remotes = (await Container.git.getRemotes(repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(repoPath);
return commands.executeCommand(Commands.OpenInRemote, uri, {
resource: {

+ 1
- 1
src/commands/openCommitInRemote.ts View File

@ -66,7 +66,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
args.sha = commit.sha;
}
const remotes = (await Container.git.getRemotes(gitUri.repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(gitUri.repoPath);
return commands.executeCommand(Commands.OpenInRemote, uri, {
resource: {

+ 1
- 1
src/commands/openFileInRemote.ts View File

@ -45,7 +45,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
}
try {
const remotes = (await Container.git.getRemotes(gitUri.repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(gitUri.repoPath);
const range = (args.range && editor !== undefined)
? new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }))
: undefined;

+ 1
- 1
src/commands/openRepoInRemote.ts View File

@ -34,7 +34,7 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
if (!repoPath) return undefined;
try {
const remotes = (await Container.git.getRemotes(repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(repoPath);
return commands.executeCommand(Commands.OpenInRemote, uri, {
resource: {

+ 7
- 3
src/gitService.ts View File

@ -1073,15 +1073,19 @@ export class GitService extends Disposable {
}
}
async getRemotes(repoPath: string | undefined): Promise<GitRemote[]> {
async getRemotes(repoPath: string | undefined, options: { includeAll?: boolean } = {}): Promise<GitRemote[]> {
if (repoPath === undefined) return [];
Logger.log(`getRemotes('${repoPath}')`);
const repository = await this.getRepository(repoPath);
if (repository !== undefined) return repository.getRemotes();
const remotes = repository !== undefined
? repository.getRemotes()
: this.getRemotesCore(repoPath);
return this.getRemotesCore(repoPath);
if (options.includeAll) return remotes;
return (await remotes).filter(r => r.provider !== undefined);
}
async getRemotesCore(repoPath: string | undefined, providerMap?: RemoteProviderMap): Promise<GitRemote[]> {

+ 1
- 1
src/quickPicks/branchHistoryQuickPick.ts View File

@ -36,7 +36,7 @@ export class BranchHistoryQuickPick {
} as ShowQuickBranchHistoryCommandArgs
]);
const remotes = (await Container.git.getRemotes((uri && uri.repoPath) || log.repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes((uri && uri.repoPath) || log.repoPath);
if (remotes.length) {
items.splice(0, 0, new OpenRemotesCommandQuickPickItem(remotes, {
type: 'branch',

+ 1
- 1
src/quickPicks/commitFileQuickPick.ts View File

@ -120,7 +120,7 @@ export class CommitFileQuickPick {
}
items.push(new OpenCommitFileRevisionCommandQuickPickItem(commit));
const remotes = (await Container.git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(commit.repoPath);
if (remotes.length) {
if (commit.workingFileName && commit.status !== 'D') {
const branch = await Container.git.getBranch(commit.repoPath);

+ 1
- 1
src/quickPicks/commitQuickPick.ts View File

@ -129,7 +129,7 @@ export class CommitQuickPick {
else {
items.splice(index++, 0, new ShowCommitInResultsQuickPickItem(commit));
const remotes = (await Container.git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(commit.repoPath);
if (remotes.length) {
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
type: 'commit',

+ 1
- 1
src/quickPicks/fileHistoryQuickPick.ts View File

@ -110,7 +110,7 @@ export class FileHistoryQuickPick {
]));
}
const remotes = (await Container.git.getRemotes(uri.repoPath!)).filter(r => r.provider !== undefined);
const remotes = await Container.git.getRemotes(uri.repoPath!);
if (remotes.length) {
const resource = uri.sha !== undefined
? {

Loading…
Cancel
Save