8000 Master PR for refactoring connections by grokys · Pull Request #1277 · github/VisualStudio · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Master PR for refactoring connections #1277

Merged
merged 43 commits into from
Nov 21, 2017
Merged

Conversation

grokys
Copy link
Contributor
@grokys grokys commented Oct 20, 2017

This PR will serve as a master PR for connection refactor work. This is a protected branch, submit PRs to this branch to modify.

The Plan

Merge duplicate classes

There are 2 ways to do a lot of things, a situation caused by having to remove Rx from Team Explorer at the last minute. Refactor everything into a single class for each concern, using Tasks rather than observables.

Harden Credentials

Store our own "master" credential in the Windows Credential store which we can restore on startup.

Remove IRepositoryHost(s)

Merge IConnectionManager and IRepositoryHosts into IConnectionManager - RepositoryHosts is old code ported from the .NET desktop app. It does pretty much the same thing as IConnectionManager except it gets the list of connections from the Windows Credential Manager instead of connections.json which causes #1242 and #1094.

Future: Provide better failure modes

Currently if VS is started up disconnected from the internet, the connection is simply removed from Team Explorer. We need to display a message with a "Retry" button or similar if a connection error happens, and similarly display a "You need to log in again" button or similar if the users credentials have changed. This will be done in a separate, future PR,

PRs to be merged in/already merged in:

grokys and others added 18 commits August 25, 2017 13:29
Previously credentials were read by 4 separate interfaces/classes:

- `IKeychain`/`WindowsKeychain`
- `ILoginCache`/`LoginCache`
- `SimpleCredentialStore`
- `CredentialCache`

Make everything go via `IKeychain`.
Just call `ToObservable` on the task returned by `IKeychain`.
 Conflicts:
	src/GitHub.App/Models/RepositoryHost.cs
	src/UnitTests/GitHub.App/Models/RepositoryHostTests.cs
Store our own "master" credential in the Windows Credential store that is unlikely to get overwritten.
Removed `IConnection.Repositories` and `IConnectionManager.RefreshRepositories` and replaced them with `LocalRepositories` which acts as a central place to find known repositories.

As part of this, also added `IReadOnlyObservableCollection` and `ObservableCollectionEx` because the BCL's `ReadOnlyObservableCollection` sucks. Made `TrackingCollection` implement `IReadOnlyObservableCollection`.
grokys and others added 12 commits November 3, 2017 17:12
…connection-manager

 Conflicts:
	src/GitHub.InlineReviews/Services/PullRequestSessionManager.cs
	src/UnitTests/GitHub.VisualStudio/Services/ConnectionManagerTests.cs
When creating a `ModelService`, ensure that the correct `AccountCacheItem` is inserted.
 Conflicts:
	src/GitHub.App/Caches/LoginCache.cs
	src/GitHub.App/Caches/SharedCache.cs
	src/GitHub.App/Factories/ApiClientFactory.cs
	src/GitHub.App/Models/RepositoryHost.cs
	src/GitHub.App/Services/GitHubCredentialStore.cs
…local-repositories

 Conflicts:
	src/GitHub.VisualStudio/Services/ConnectionManager.cs
…connection-manager

 Conflicts:
	src/GitHub.App/Models/RepositoryHost.cs
	src/GitHub.App/Models/RepositoryHosts.cs
	src/GitHub.App/ViewModels/PullRequestListViewModel.cs
	src/GitHub.VisualStudio/Services/ConnectionManager.cs
…remove-repositoryhosts

 Conflicts:
	src/GitHub.App/Models/RepositoryHost.cs
	src/GitHub.App/Models/RepositoryHosts.cs
	src/GitHub.App/Services/ModelService.cs
	src/GitHub.App/ViewModels/GistCreationViewModel.cs
	src/GitHub.App/ViewModels/LoginTabViewModel.cs
	src/GitHub.App/ViewModels/PullRequestCreationViewModel.cs
	src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs
	src/GitHub.App/ViewModels/PullRequestListViewModel.cs
	src/GitHub.App/ViewModels/RepositoryCloneViewModel.cs
	src/GitHub.App/ViewModels/RepositoryCreationViewModel.cs
	src/GitHub.App/ViewModels/RepositoryPublishViewModel.cs
	src/GitHub.InlineReviews/Services/PullRequestSessionManager.cs
 Conflicts:
	src/GitHub.App/ViewModels/PullRequestCreationViewModel.cs
	test/UnitTests/GitHub.App/Caches/CredentialCacheTests.cs
	test/UnitTests/GitHub.App/Models/RepositoryHostTests.cs
	test/UnitTests/GitHub.App/ViewModels/PullRequestCreationViewModelTests.cs
	test/UnitTests/Helpers/TestLoginCache.cs
shana
shana previously approved these changes Nov 17, 2017
Copy link
Contributor
@shana shana left a comment

Choose a reason for hiding this comment

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

This looks good and the PRs that compose it have already been separately reviewed 👍

A few things that are important to note following this:

  • Visual Studio Login with Email #1297 Making sure the username is always saved in the credential manager in all the entries. Even though it's not technically needed for using the token, it's useful for knowing what user created it in order to recreate connections later if data goes out of sync without having to explicitely ping the API for it, which is especially important if the internet goes out while we're doing this (we need to know the user to query the akavache database for most cached things)
  • Create connection from credential #1331 Hardening and testing the credential manager and connection data link - if we have the custom credential manager entry but one of the other entries is missing or the connection entry is missing in our json file, recreate them. This is something we're probably doing already, but we should test to make sure it's sturdy
  • Testing the interaction between GitHub for Unity logout/login with GHfVS. Can GHfVS recover if GHfU (or other git clients, really) stomps all over its credentials?
  • Validate scopes for login. #1332 Validating the token for permission scopes. If other git clients replace the token, they may not create one with the correct scopes, we need to handle that.
  • Share login credentials between GHfVS and GHfU. #1333 Getting together with @StanleyGoldman to figure out what's a good way of sharing credential and user information across GHfVS and GHfU so that you can login on one side and use the other seamlessly

 Conflicts:
	src/GitHub.App/Models/RepositoryHost.cs
	src/GitHub.App/Services/PullRequestService.cs
	src/GitHub.App/ViewModels/RepositoryCreationViewModel.cs
	src/GitHub.App/ViewModels/RepositoryPublishViewModel.cs
	test/UnitTests/GitHub.App/Models/RepositoryHostTests.cs
 Conflicts:
	src/GitHub.App/ViewModels/PullRequestListViewModel.cs
Copy link
Collaborator
@jcansdale jcansdale left a comment

Choose a reason for hiding this comment

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

Looks good to me. You were going to add @shana's suggestions as separate issues/PRs?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0