Skip to content

Use isSameAccount for account identity comparisons - #23021

Merged
niik merged 10 commits into
niik-repository-account-associationfrom
niik-use-issameaccount-comparisons
Nov 3, 2026
Merged

niik merged 10 commits into
niik-repository-account-associationfrom
niik-use-issameaccount-comparisons

Conversation

@niik

@niik niik commented Oct 15, 2026

Copy link
Copy Markdown
Member

Stacked on #23020.

Description

This is a pure refactor with no behaviour change. It replaces the hand-written "same endpoint and case-insensitively equal login" checks introduced in #23020 with the existing isSameAccount helper. It also adds getRepositoryAccountIdentity(repository): IAccountIdentity | null to models/repository.ts, which returns the identity of a repository's assigned account, or null when the repository has no GitHub repository or no login.

Replaced (11 sites)

  • getAccountForRepository
  • repository-matching.ts (verifying the selected account)
  • trampoline-credential-helper.ts (fallback account lookup)
  • RepositoriesStore.clearAccountAssignments
  • AppStore:
    • clone with an explicit account
    • _signOutAccount repository count
    • _updateRepositoryAccount signed-in check
    • the account lookup after choosing a repository account
  • RepositoryAccountDialog: requiresSignIn and onAssignedAccountSignInResult
  • RepositorySettings.selectedAccount

Deliberately left alone

  • AppStore._selectRepository ruleset cache invalidation and the current.login !== repository.login check during repository refresh. These detect any change to the assignment, so they compare strictly (case-sensitive, and null equals null). They aren't identity checks.
  • Login-only matches in RepositoryAccountDialog (onAccountChanged, accounts). They match the exact <select> value within a list that is already filtered by endpoint.
  • Endpoint-only checks; the precomputed getAccountKey(a) === key lookups in AccountsStore (one of them also compares id); persisted DB record and index comparisons; owner, repository and email matching.
  • accountEquals, which compares endpoint and id and so has different semantics.

Note

isSameAccount compares endpoints case-insensitively, while the old checks used ===. Endpoints are normalized API URLs (built from URL.host), and getAccountKey is already the account identity in AccountsStore, so nothing changes in practice.

Validation

  • tsc --noEmit passes.
  • Full test suite: 2404 pass, 0 fail.
  • eslint and prettier are clean.

Release notes

Notes: no-notes

Replace hand-written endpoint + case-insensitive login comparisons with
isSameAccount, and add getRepositoryAccountIdentity to build the identity
of a repository's assigned account. No behaviour change.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 10:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused refactor preserves intended identity matching and null handling, with no unresolved findings.

No open issues 🎉

What changed in this PR

Consolidates repository account identity comparisons using existing helpers, building on the multi-account support in #23020.

Changes:

  • Replaces 11 handwritten comparisons with isSameAccount.
  • Adds getRepositoryAccountIdentity for nullable repository assignments.
  • Leaves strict assignment-change checks unchanged.
File Description
app/​src/​ui/​repository-settings/​repository-settings.tsx Simplifies selected-account matching.
app/​src/​ui/​repository-account/​repository-account-dialog.tsx Reuses helpers for sign-in checks.
app/​src/​models/​repository.ts Adds repository account identity helper.
app/​src/​lib/​trampoline/​trampoline-credential-helper.ts Simplifies fallback credential account lookup.
app/​src/​lib/​stores/​repositories-store.ts Reuses helpers when clearing assignments.
app/​src/​lib/​stores/​app-store.ts Consolidates clone, sign-out, and account-selection checks.
app/​src/​lib/​repository-matching.ts Simplifies selected-account verification.
app/​src/​lib/​get-account-for-repository.ts Centralizes assigned-account lookup.

Review effort: Balanced

@niik
niik marked this pull request as ready for review October 19, 2026 15:06
@niik
niik requested a review from a team as a code owner October 19, 2026 15:06
@niik
niik requested a review from BagToad October 19, 2026 15:06
sergiou87
sergiou87 previously approved these changes Oct 21, 2026
@niik
niik merged commit 2d36510 into development Nov 3, 2026
9 checks passed
@niik
niik deleted the niik-use-issameaccount-comparisons branch November 3, 2026 09:37
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.

3 participants