diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c0136e..f2a836b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [1336](https://github.com/eamodio/vscode-gitlens/issues/1336) - Need to allow GitLens to connect to GitHub in every Codespace (requires VS Code v1.54-insiders or later) - Fixes [1363](https://github.com/eamodio/vscode-gitlens/issues/1363) - Error 'Unable to open compare', when git setting log.showsignature is active - Fixes [1368](https://github.com/eamodio/vscode-gitlens/issues/1368) - Suppress message "GitLens was unable to find Git" - Fixes typo in README — thanks to [PR #1374](https://github.com/eamodio/vscode-gitlens/pull/1374) by David Rees ([@studgeek](https://github.com/studgeek)) diff --git a/package.json b/package.json index bcb0b44..c7c453d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/eamodio/vscode-gitlens.git" }, "engines": { - "vscode": "^1.53.0" + "vscode": "^1.54.0-insiders" }, "main": "./dist/gitlens", "icon": "images/gitlens-icon.png", @@ -3357,11 +3357,6 @@ } }, { - "command": "gitlens.resetRemoteConnectionAuthorization", - "title": "Reset Remote Connection Authorization", - "category": "GitLens" - }, - { "command": "gitlens.copyCurrentBranch", "title": "Copy Current Branch Name", "category": "GitLens", @@ -5218,10 +5213,6 @@ "when": "config.gitlens.integrations.enabled && gitlens:hasRichRemotes && gitlens:hasConnectedRemotes" }, { - "command": "gitlens.resetRemoteConnectionAuthorization", - "when": "config.gitlens.integrations.enabled && gitlens:hasRichRemotes" - }, - { "command": "gitlens.copyCurrentBranch", "when": "gitlens:enabled" }, diff --git a/src/commands.ts b/src/commands.ts index a3c1116..5136751 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -40,7 +40,6 @@ export * from './commands/rebaseEditor'; export * from './commands/refreshHover'; export * from './commands/remoteProviders'; export * from './commands/repositories'; -export * from './commands/resetRemoteConnectionAuthorization'; export * from './commands/resetSuppressedWarnings'; export * from './commands/setViewsLayout'; export * from './commands/searchCommits'; diff --git a/src/commands/common.ts b/src/commands/common.ts index 80ea079..0fbcc5c 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -101,7 +101,6 @@ export enum Commands { GitCommands = 'gitlens.gitCommands', QuickOpenFileHistory = 'gitlens.quickOpenFileHistory', RefreshHover = 'gitlens.refreshHover', - ResetRemoteConnectionAuthorization = 'gitlens.resetRemoteConnectionAuthorization', ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings', RevealCommitInView = 'gitlens.revealCommitInView', SearchCommits = 'gitlens.showCommitSearch', diff --git a/src/commands/resetRemoteConnectionAuthorization.ts b/src/commands/resetRemoteConnectionAuthorization.ts deleted file mode 100644 index e8217e4..0000000 --- a/src/commands/resetRemoteConnectionAuthorization.ts +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; -import { Container } from '../container'; -import { command, Command, Commands } from './common'; - -@command() -export class ResetRemoteConnectionAuthorizationCommand extends Command { - constructor() { - super(Commands.ResetRemoteConnectionAuthorization); - } - - async execute() { - for (const repo of await Container.git.getRepositories()) { - const remote = await Container.git.getRichRemoteProvider(repo.path, { includeDisconnected: true }); - await remote?.provider?.resetRemoteConnectionAuthorization(); - } - } -} diff --git a/src/constants.ts b/src/constants.ts index ad1dc9b..e9a22a3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -150,10 +150,11 @@ export enum GlyphChars { } export enum SyncedState { - DisallowConnectionPrefix = 'gitlens:disallow:connection:', UpdatesViewVisible = 'gitlens:views:updates:visible', Version = 'gitlens:synced:version', WelcomeViewVisible = 'gitlens:views:welcome:visible', + + Deprecated_DisallowConnectionPrefix = 'gitlens:disallow:connection:', } export enum GlobalState { @@ -235,7 +236,6 @@ export enum WorkspaceState { BranchComparisons = 'gitlens:branch:comparisons', ConnectedPrefix = 'gitlens:connected:', DefaultRemote = 'gitlens:remote:default', - DisallowConnectionPrefix = 'gitlens:disallow:connection:', GitCommandPaletteUsage = 'gitlens:gitComandPalette:usage', StarredBranches = 'gitlens:starred:branches', StarredRepositories = 'gitlens:starred:repositories', @@ -243,5 +243,6 @@ export enum WorkspaceState { ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults', ViewsSearchAndComparePinnedItems = 'gitlens:views:searchAndCompare:pinned', + Deprecated_DisallowConnectionPrefix = 'gitlens:disallow:connection:', Deprecated_PinnedComparisons = 'gitlens:pinned:comparisons', } diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index 6cddf97..1a9e7f3 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -6,16 +6,13 @@ import { env, Event, EventEmitter, - MessageItem, Range, Uri, - window, } from 'vscode'; import { DynamicAutolinkReference } from '../../annotations/autolinks'; import { AutolinkReference } from '../../config'; -import { SyncedState, WorkspaceState } from '../../constants'; +import { WorkspaceState } from '../../constants'; import { Container } from '../../container'; -import { setKeysForSync } from '../../extension'; import { Logger } from '../../logger'; import { Account, @@ -286,14 +283,6 @@ export abstract class RichRemoteProvider extends RemoteProvider { return `${WorkspaceState.ConnectedPrefix}${this.key}`; } - private get disallowSyncedGlobalConnectionKey() { - return `${SyncedState.DisallowConnectionPrefix}${this.key}`; - } - - private get disallowWorkspaceConnectionKey() { - return `${WorkspaceState.DisallowConnectionPrefix}${this.key}`; - } - get maybeConnected(): boolean | undefined { if (this._session === undefined) return undefined; @@ -310,7 +299,7 @@ export abstract class RichRemoteProvider extends RemoteProvider { private onAuthenticationSessionsChanged(e: AuthenticationSessionsChangeEvent) { if (e.provider.id === this.authProvider.id) { - this.disconnect(); + void this.ensureSession(false); } } @@ -333,8 +322,7 @@ export abstract class RichRemoteProvider extends RemoteProvider { this._session = null; if (disconnected) { - void Container.context.workspaceState.update(this.connectedKey, undefined); - void Container.context.workspaceState.update(this.disallowWorkspaceConnectionKey, true); + void Container.context.workspaceState.update(this.connectedKey, false); this._onDidChange.fire(); if (!silent) { @@ -343,15 +331,6 @@ export abstract class RichRemoteProvider extends RemoteProvider { } } - @log() - async resetRemoteConnectionAuthorization() { - await Promise.all([ - Container.context.workspaceState.update(this.connectedKey, undefined), - Container.context.workspaceState.update(this.disallowWorkspaceConnectionKey, undefined), - Container.context.globalState.update(this.disallowSyncedGlobalConnectionKey, undefined), - ]); - } - @gate() @debug({ exit: connected => `returned ${connected}`, @@ -544,15 +523,8 @@ export abstract class RichRemoteProvider extends RemoteProvider { if (!Container.config.integrations.enabled) return undefined; if (createIfNeeded) { - await Promise.all([ - Container.context.workspaceState.update(this.connectedKey, undefined), - Container.context.workspaceState.update(this.disallowWorkspaceConnectionKey, undefined), - ]); - } else if ( - !Container.context.workspaceState.get(this.connectedKey) && - (Container.context.globalState.get(this.disallowSyncedGlobalConnectionKey) || - Container.context.workspaceState.get(this.disallowWorkspaceConnectionKey)) - ) { + await Container.context.workspaceState.update(this.connectedKey, undefined); + } else if (Container.context.workspaceState.get(this.connectedKey) === false) { return undefined; } @@ -562,15 +534,9 @@ export abstract class RichRemoteProvider extends RemoteProvider { createIfNone: createIfNeeded, }); } catch (ex) { - await Promise.all([ - Container.context.workspaceState.update(this.connectedKey, undefined), - Container.context.workspaceState.update(this.disallowWorkspaceConnectionKey, true), - ]); + await Container.context.workspaceState.update(this.connectedKey, undefined); if (ex instanceof Error && ex.message.includes('User did not consent')) { - if (!createIfNeeded) { - void this.promptToAllow(true); - } return undefined; } @@ -578,55 +544,22 @@ export abstract class RichRemoteProvider extends RemoteProvider { } if (session === undefined && !createIfNeeded) { - await Promise.all([ - Container.context.workspaceState.update(this.connectedKey, undefined), - Container.context.workspaceState.update(this.disallowWorkspaceConnectionKey, true), - ]); - - void this.promptToAllow(); + await Container.context.workspaceState.update(this.connectedKey, undefined); } this._session = session ?? null; this.invalidClientExceptionCount = 0; if (session != null) { - await Promise.all([ - Container.context.workspaceState.update(this.connectedKey, true), - Container.context.workspaceState.update(this.disallowWorkspaceConnectionKey, undefined), - ]); - - if (createIfNeeded) { - this._onDidChange.fire(); - _onDidChangeAuthentication.fire({ reason: 'connected', key: this.key }); - } + await Container.context.workspaceState.update(this.connectedKey, true); + + this._onDidChange.fire(); + _onDidChangeAuthentication.fire({ reason: 'connected', key: this.key }); } return session ?? undefined; } - @gate() - private async promptToAllow(retry: boolean = false) { - const allow: MessageItem = { title: 'Allow' }; - const deny: MessageItem = { title: 'Deny' }; - const denyEverywhere: MessageItem = { title: 'Deny Everywhere' }; - - const result = await window.showInformationMessage( - retry - ? `By allowing GitLens to connect to ${this.name}, it can provide a rich integration with pull requests, issues, avatars, and more.\n\nIf you choose 'Allow', you will again be prompted to authenticate with ${this.name}.` - : `Allow GitLens to connect to ${this.name} to provide a rich integration with pull requests, issues, avatars, and more.\n\nIf you choose 'Allow', you will be prompted to authenticate with ${this.name}.`, - allow, - deny, - denyEverywhere, - ); - - if (result === allow) { - void this.connect(); - } else if (result === denyEverywhere) { - setKeysForSync(this.disallowSyncedGlobalConnectionKey); - await Container.context.globalState.update(this.disallowSyncedGlobalConnectionKey, true); - } - } - @debug() private handleClientException() { this.invalidClientExceptionCount++;