Browse Source

Sets remote default when connecting (if not set)

main
Eric Amodio 5 years ago
parent
commit
e8cb439ed9
3 changed files with 13 additions and 7 deletions
  1. +9
    -4
      src/commands/remoteProviders.ts
  2. +3
    -2
      src/git/remotes/github.ts
  3. +1
    -1
      src/git/remotes/provider.ts

+ 9
- 4
src/commands/remoteProviders.ts View File

@ -39,12 +39,17 @@ export class ConnectRemoteProviderCommand extends Command {
}
async execute(args?: ConnectRemoteProviderCommandArgs): Promise<any> {
if (args?.repoPath == null || args?.remote == null) return undefined;
if (args?.repoPath == null || args?.remote == null) return false;
const remote = (await Container.git.getRemotes(args.repoPath)).find(r => args.remote);
if (!remote?.provider?.hasApi()) return undefined;
const remotes = await Container.git.getRemotes(args.repoPath);
const remote = remotes.find(r => args.remote);
if (!remote?.provider?.hasApi()) return false;
return remote.provider.connect();
const connected = await remote.provider.connect();
if (connected && !remotes.some(r => r.default)) {
await remote.setAsDefault(true);
}
return connected;
}
}

+ 3
- 2
src/git/remotes/github.ts View File

@ -101,9 +101,10 @@ export class GitHubRemote extends RemoteProviderWithApi<{ token: string }> {
disposable?.dispose();
}
if (token == null || token.length === 0) return;
if (token == null || token.length === 0) return false;
this.saveCredentials({ token: token });
await this.saveCredentials({ token: token });
return true;
}
protected getUrlForBranches(): string {

+ 1
- 1
src/git/remotes/provider.ts View File

@ -223,7 +223,7 @@ export abstract class RemoteProviderWithApi extends
abstract get apiBaseUrl(): string;
abstract async connect(): Promise<void>;
abstract async connect(): Promise<boolean>;
disconnect(): Promise<void> {
this._prsByCommit.clear();

Loading…
Cancel
Save