Skip to content

fix: clear GitHub remote source cache when session changes#308927

Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/github-remote-source-cache-on-signout
Open

fix: clear GitHub remote source cache when session changes#308927
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/github-remote-source-cache-on-signout

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

Summary

  • Clears the cached Octokit REST client and user repository list in the GitHub extension when the GitHub authentication session changes (sign-out/sign-in)
  • Makes GithubRemoteSourceProvider listen to authentication.onDidChangeSessions and reset userReposCache so previously linked repos no longer appear in the clone dialog after sign-out
  • Properly disposes the session change listener when the extension is deactivated

Test plan

  • Sign into GitHub in VS Code
  • Open Git: Clone and confirm repos from the signed-in GitHub account appear
  • Sign out of GitHub via the account menu
  • Open Git: Clone again and confirm repos from the signed-out account no longer appear (without restarting VS Code)
  • Sign back in to GitHub and confirm repos re-appear

Fixes #164868

When a user signs out of their GitHub account, the cached repository
list in GithubRemoteSourceProvider persists, allowing previously linked
repos to still appear in the clone dialog. Similarly, the module-level
Octokit instance is never invalidated on session change.

This fix:
- Adds a clearOctokitCache() function and calls it from OctokitService
  when GitHub sessions change
- Makes GithubRemoteSourceProvider listen to authentication session
  changes and clear userReposCache when the GitHub session is removed
- Properly disposes the session change listener

Fixes microsoft#164868
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/github/src/auth.ts
  • extensions/github/src/extension.ts
  • extensions/github/src/remoteSourceProvider.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub - for VSCode not properly unlinked until VSCode restart

2 participants