Skip to content

Conversation

@sergeibbb
Copy link
Member

@sergeibbb sergeibbb commented Mar 12, 2025

Description

The problem

I've noticed that here the connected variable is always boolean and can never be equal to null, so we always skip the if body here:

let connected = remote.maybeIntegrationConnected;
// If we don't know if we are connected, only check if the remote is the default or there is only one
// TODO@eamodio is the above still a valid requirement?
if (connected == null && (remote.default || remotes.length === 1)) {
const integration = await remote.getIntegration();
connected = await integration?.isConnected();
}

Therefore, integrations with unknown connection status never get saved here:

setContext(
'gitlens:repos:withHostingIntegrationsConnected',
reposWithHostingIntegrationsConnected.size ? [...reposWithHostingIntegrationsConnected] : undefined,
),

As a result we don't see them on reading. For example in the List of Remotes it didn't see a connected Bitbucket integration and didn't request for PRs:

let prPromise: Promise<PullRequest | undefined> | undefined;
if (
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForBranches &&
(branch.upstream != null || branch.remote) &&
getContext('gitlens:repos:withHostingIntegrationsConnected')?.includes(branch.repoPath)
) {

Investigation

I've noticed that the related code only changed once and the "always boolean effect" might appear occasionally.

Suggested solution

I suggest we should let it be undefined again.

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@sergeibbb sergeibbb force-pushed the bug/maybe-connected-always-bool branch from 2207af9 to 5138576 Compare March 12, 2025 09:59
Copy link
Member

@eamodio eamodio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@eamodio eamodio merged commit 542c8b0 into main Mar 13, 2025
3 checks passed
saeedzaha pushed a commit to saeedzaha/vscode-gitlens that referenced this pull request Apr 28, 2025
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.

2 participants