Skip to content

Commit 58084d9

Browse files
committed
Fixes premature negative caching of avatars
Only permanently caches "no avatar" when a provider was actually consulted, preventing fallback sources from being skipped on retry when no integration or custom remote was available. (#5155)
1 parent f42ac29 commit 58084d9

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
77
## [Unreleased]
88

99
### Added
10+
1011
- Adds an optional `avatar` URL template to custom remotes in the `gitlens.remotes` setting — enables corporate and self-hosted setups to resolve commit-author avatars via a templated URL with `${email}`, `${emailName}`, `${domain}`, and `${size}` tokens; identity values are component-encoded before interpolation to keep attacker-controllable commit emails from injecting URL-structural characters, and templates configured via workspace settings require explicit user approval on first use in a trusted workspace (revocable via _GitLens: Reset > Approved Avatar URL Templates..._) ([#302](https://github.com/gitkraken/vscode-gitlens/issues/302), [#5155](https://github.com/gitkraken/vscode-gitlens/pull/5155)) — thanks to [PR #1636](https://github.com/gitkraken/vscode-gitlens/pull/1636) by Tmk ([@tmkx](https://github.com/tmkx))
1112

1213
## [18.0.0] - 2026-05-27

src/avatars.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,15 @@ async function getAvatarUriFromRemoteProvider(
232232

233233
try {
234234
let account: CommitAuthor | undefined;
235+
let hasAvatarSource = false;
235236
// if (typeof repoPathOrCommit === 'string') {
236237
// const remote = await Container.instance.git.getRichRemoteProvider(repoPathOrCommit);
237238
// account = await remote?.provider.getAccountForEmail(email, { avatarSize: size });
238239
// } else {
239240
if (typeof repoPathOrCommit !== 'string') {
240241
const remote = await getBestRemoteWithIntegration(repoPathOrCommit.repoPath);
241242
if (remote != null && remoteSupportsIntegration(remote)) {
243+
hasAvatarSource = true;
242244
account = await (
243245
await getRemoteIntegration(remote)
244246
)?.getAccountForCommit(remote.provider.repoDesc, repoPathOrCommit.ref, {
@@ -266,10 +268,12 @@ async function getAvatarUriFromRemoteProvider(
266268
}
267269

268270
if (account?.avatarUrl == null) {
269-
// If we have no account assume that won't change (without a reset), so set the timestamp to "never expire"
270-
avatar.uri = undefined;
271-
avatar.timestamp = Infinity;
272-
avatar.retries = 0;
271+
if (hasAvatarSource) {
272+
// A provider was consulted but returned no avatar — permanently cache "no result"
273+
avatar.uri = undefined;
274+
avatar.timestamp = Infinity;
275+
avatar.retries = 0;
276+
}
273277

274278
return undefined;
275279
}

0 commit comments

Comments
 (0)