Skip to content

Commit 1b12e80

Browse files
Updates GitHub git provider to always use local session
1 parent 11153ef commit 1b12e80

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/plus/integrations/providers/github/githubGitProvider.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type {
1010
} from 'vscode';
1111
import { EventEmitter, FileType, Uri, window, workspace } from 'vscode';
1212
import { encodeUtf8Hex } from '@env/hex';
13-
import { isWeb } from '@env/platform';
1413
import { CharCode, Schemes } from '../../../../constants';
1514
import { HostingIntegrationId } from '../../../../constants.integrations';
1615
import type { Container } from '../../../../container';
@@ -1459,42 +1458,37 @@ export class GitHubGitProvider implements GitProvider, Disposable {
14591458

14601459
private _sessionPromise: Promise<AuthenticationSession> | undefined;
14611460
private async ensureSession(force: boolean = false, silent: boolean = false): Promise<AuthenticationSession> {
1462-
// never get silent in web environments, because we assume that we always have a github session there:
1463-
silent = silent && !isWeb;
14641461
if (force || this._sessionPromise == null) {
14651462
async function getSession(this: GitHubGitProvider): Promise<AuthenticationSession> {
14661463
let skip = this.container.storage.get(`provider:authentication:skip:${this.descriptor.id}`, false);
1467-
const authenticationProvider = await this.authenticationService.get(this.authenticationProviderId);
1468-
let options:
1469-
| { forceNewSession: true; createIfNeeded?: never; silent?: never }
1470-
| { forceNewSession?: never; createIfNeeded: true; silent?: never }
1471-
| { forceNewSession?: never; createIfNeeded?: never; silent: true } = isWeb
1472-
? { createIfNeeded: true }
1473-
: { silent: true };
14741464

14751465
try {
1466+
let session;
14761467
if (force) {
14771468
skip = false;
14781469
void this.container.storage.delete(`provider:authentication:skip:${this.descriptor.id}`);
1479-
options = { forceNewSession: true };
1470+
1471+
session = await getBuiltInIntegrationSession(
1472+
this.container,
1473+
HostingIntegrationId.GitHub,
1474+
this.authenticationDescriptor,
1475+
{ forceNewSession: true },
1476+
);
14801477
} else if (!skip && !silent) {
1481-
options = { createIfNeeded: true };
1478+
session = await getBuiltInIntegrationSession(
1479+
this.container,
1480+
HostingIntegrationId.GitHub,
1481+
this.authenticationDescriptor,
1482+
{ createIfNeeded: true },
1483+
);
14821484
} else {
1483-
options = isWeb ? { createIfNeeded: true } : { silent: true };
1485+
session = await getBuiltInIntegrationSession(
1486+
this.container,
1487+
HostingIntegrationId.GitHub,
1488+
this.authenticationDescriptor,
1489+
);
14841490
}
14851491

1486-
const session = isWeb
1487-
? await getBuiltInIntegrationSession(
1488-
this.container,
1489-
HostingIntegrationId.GitHub,
1490-
this.authenticationDescriptor,
1491-
options,
1492-
)
1493-
: await authenticationProvider.getSession(
1494-
this.authenticationDescriptor,
1495-
options.silent ? undefined : options,
1496-
);
1497-
14981492
if (session != null) return session;
14991493

15001494
throw new Error('User did not consent');

0 commit comments

Comments
 (0)