GitHub - add setting to disable avatar resolution (#238270)
parent
4b4cd6b702
commit
7667cdd1ed
|
@ -195,6 +195,12 @@
|
||||||
],
|
],
|
||||||
"default": "https",
|
"default": "https",
|
||||||
"description": "%config.gitProtocol%"
|
"description": "%config.gitProtocol%"
|
||||||
|
},
|
||||||
|
"github.showAvatar": {
|
||||||
|
"type": "boolean",
|
||||||
|
"scope": "resource",
|
||||||
|
"default": true,
|
||||||
|
"description": "%config.showAvatar%"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"config.branchProtection": "Controls whether to query repository rules for GitHub repositories",
|
"config.branchProtection": "Controls whether to query repository rules for GitHub repositories",
|
||||||
"config.gitAuthentication": "Controls whether to enable automatic GitHub authentication for git commands within VS Code.",
|
"config.gitAuthentication": "Controls whether to enable automatic GitHub authentication for git commands within VS Code.",
|
||||||
"config.gitProtocol": "Controls which protocol is used to clone a GitHub repository",
|
"config.gitProtocol": "Controls which protocol is used to clone a GitHub repository",
|
||||||
|
"config.showAvatar": "Controls whether to show the GitHub avatar of the commit author in various hovers (ex: Git blame, Timeline, Source Control Graph, etc.)",
|
||||||
"welcome.publishFolder": {
|
"welcome.publishFolder": {
|
||||||
"message": "You can directly publish this folder to a GitHub repository. Once published, you'll have access to source control features powered by Git and GitHub.\n[$(github) Publish to GitHub](command:github.publish)",
|
"message": "You can directly publish this folder to a GitHub repository. Once published, you'll have access to source control features powered by Git and GitHub.\n[$(github) Publish to GitHub](command:github.publish)",
|
||||||
"comment": [
|
"comment": [
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { authentication, Command, l10n, LogOutputChannel } from 'vscode';
|
import { authentication, Command, l10n, LogOutputChannel, workspace } from 'vscode';
|
||||||
import { Commit, Repository as GitHubRepository, Maybe } from '@octokit/graphql-schema';
|
import { Commit, Repository as GitHubRepository, Maybe } from '@octokit/graphql-schema';
|
||||||
import { API, AvatarQuery, AvatarQueryCommit, Repository, SourceControlHistoryItemDetailsProvider } from './typings/git';
|
import { API, AvatarQuery, AvatarQueryCommit, Repository, SourceControlHistoryItemDetailsProvider } from './typings/git';
|
||||||
import { DisposableStore, getRepositoryDefaultRemote, getRepositoryDefaultRemoteUrl, getRepositoryFromUrl, groupBy, sequentialize } from './util';
|
import { DisposableStore, getRepositoryDefaultRemote, getRepositoryDefaultRemoteUrl, getRepositoryFromUrl, groupBy, sequentialize } from './util';
|
||||||
|
@ -78,7 +78,7 @@ function compareAvatarQuery(a: AvatarQueryCommit, b: AvatarQueryCommit): number
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GitHubSourceControlHistoryItemDetailsProvider implements SourceControlHistoryItemDetailsProvider {
|
export class GitHubSourceControlHistoryItemDetailsProvider implements SourceControlHistoryItemDetailsProvider {
|
||||||
private _enabled = true;
|
private _isUserAuthenticated = true;
|
||||||
private readonly _store = new Map<string, GitHubRepositoryStore>();
|
private readonly _store = new Map<string, GitHubRepositoryStore>();
|
||||||
private readonly _disposables = new DisposableStore();
|
private readonly _disposables = new DisposableStore();
|
||||||
|
|
||||||
|
@ -87,16 +87,27 @@ export class GitHubSourceControlHistoryItemDetailsProvider implements SourceCont
|
||||||
|
|
||||||
this._disposables.add(authentication.onDidChangeSessions(e => {
|
this._disposables.add(authentication.onDidChangeSessions(e => {
|
||||||
if (e.provider.id === 'github') {
|
if (e.provider.id === 'github') {
|
||||||
this._enabled = true;
|
this._isUserAuthenticated = true;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this._disposables.add(workspace.onDidChangeConfiguration(e => {
|
||||||
|
if (!e.affectsConfiguration('github.showAvatar')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._store.clear();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async provideAvatar(repository: Repository, query: AvatarQuery): Promise<Map<string, string | undefined> | undefined> {
|
async provideAvatar(repository: Repository, query: AvatarQuery): Promise<Map<string, string | undefined> | undefined> {
|
||||||
this._logger.trace(`[GitHubSourceControlHistoryItemDetailsProvider][provideAvatar] Avatar resolution for ${query.commits.length} commit(s) in ${repository.rootUri.fsPath}.`);
|
this._logger.trace(`[GitHubSourceControlHistoryItemDetailsProvider][provideAvatar] Avatar resolution for ${query.commits.length} commit(s) in ${repository.rootUri.fsPath}.`);
|
||||||
|
|
||||||
if (!this._enabled) {
|
const config = workspace.getConfiguration('github', repository.rootUri);
|
||||||
this._logger.trace(`[GitHubSourceControlHistoryItemDetailsProvider][provideAvatar] Avatar resolution is disabled.`);
|
const showAvatar = config.get<boolean>('showAvatar', true) === true;
|
||||||
|
|
||||||
|
if (!this._isUserAuthenticated || !showAvatar) {
|
||||||
|
this._logger.trace(`[GitHubSourceControlHistoryItemDetailsProvider][provideAvatar] Avatar resolution is disabled. (${showAvatar === false ? 'setting' : 'auth'})`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +196,7 @@ export class GitHubSourceControlHistoryItemDetailsProvider implements SourceCont
|
||||||
// signed in with their GitHub account or they have signed out. Disable the
|
// signed in with their GitHub account or they have signed out. Disable the
|
||||||
// avatar resolution until the user signes in with their GitHub account.
|
// avatar resolution until the user signes in with their GitHub account.
|
||||||
if (err instanceof AuthenticationError) {
|
if (err instanceof AuthenticationError) {
|
||||||
this._enabled = false;
|
this._isUserAuthenticated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
Loading…
Reference in New Issue