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

Warn when no origin remote - #2026

Merged
jcansdale merged 42 commits into
masterfrom
fixes/1729-warn-when-no-origin
Nov 29, 2018
Merged

Warn when no origin remote#2026
jcansdale merged 42 commits into
masterfrom
fixes/1729-warn-when-no-origin

Conversation

@jcansdale

@jcansdalejcansdale commented Nov 1, 2018

Copy link
Copy Markdown
Collaborator

What this PR does

If a repository doesn't have a remote named origin, the extension doesn't know which remote to use or even if it's dealing with a GitHub repository. This PR shows a call-out notification if a repository has remotes but none of them are named origin. If the used clicks on the notification title, the GitHub pane will open with an option to edit their remotes.

  • Add TippingService for displaying call-out notifications on Visual Studio 2015, 2017 and 2019
  • Display NoRemoteOriginView on GitHub pane when there are no remotes named origin
  • Add ShowRepositorySettingsRemotesAsync to ITeamExplorerServices
  • Prevent exception in GetSessionInternal when repository CloneUrl changes to null
  • Add integration tests for GitService (that use a real repository)
  • Add HasRemotesButNoOrigin property to LocalRepositoryModel
  • Add CantFindGitHubUrlForRepository and RepositoriesMustHaveRemoteOrigin to Resources
    • These contain text for the notification and the pane view
  • Add TrackedRemoteName to BranchModel
    • This property has tests but isn't currently used. I thought NoRemoteOriginView might suggest renaming the currently active remote (if any) to origin?

Reviewers

  • Is the wording of the call-out / pane view clear enough?

What to expect

When a repository has at least one remote, but no remotes called "origin", the following call-out notification will appear.

image

Clicking the bonded title will open the GitHub pane, which will show the following message. Alternatively, clicking Always ignore will cause the call-out notification to never show again.

image

Clicking the Edit Remotes button will open the Repository Settings page with the Remotes section visible. This lets the user rename one of their remotes to origin.

image

To do

  • Expand text on GitHub pane to guide user towards fix
  • Add metrics

How to test

  1. Open solution from a repository on GitHub
  2. From command line type
    git remote rename origin porigin
  3. Expect call-out notification to appear
  4. Click on title of call-out notification
  5. Expect GitHub pane to appear with no "origin" message
  6. Click on the Edit Remotes button
  7. Expect Repository Settings page with the Remotes section visible
  8. Edit the porigin rename and rename it to origin
  9. Expect PR list to appear on GitHub pane

Related

Fixes#1729

This is a façade for the internal SVsTippingService on Visual Studio
2015 and 2017.
@jcansdale
jcansdaleforce-pushed the fixes/1729-warn-when-no-origin branch from cc0998b to e25a915CompareNovember 8, 2018 16:41
@jcansdale

jcansdale commented Nov 13, 2018

Copy link
Copy Markdown
CollaboratorAuthor

Exception thrown when renaming origin remote.
image

GitHub.Exports.dll!GitHub.Primitives.HostAddress.Create(string host = null) Line 38	C#	Symbols loaded.
GitHub.InlineReviews.dll!GitHub.InlineReviews.Services.PullRequestSessionManager.GetSessionInternal(string owner = "jcansdale", string name = "SnippetColorizer8", int number = 4) Line 241	C#	Symbols loaded.
GitHub.InlineReviews.dll!GitHub.InlineReviews.Services.PullRequestSessionManager.StatusChanged() Line 214	C#	Symbols loaded.

Edit: fixed in 835ebb1

@jcansdalejcansdale changed the title [wip] Warn when no origin remoteWarn when no origin remoteNov 13, 2018
This is more explicit about what it actually checks.
Allow easy navigation to Repository Settings > Remotes section.
Comment threadsrc/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs Outdated
Comment threadsrc/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs Outdated
Comment threadsrc/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs Outdated
Using the current method as a template was useful while prototyping,
but it's time to lock down the parameter types.
Explicitly look for RequestCalloutDisplay on IVsTippingService rather
than duck-type the service object.
These are used to find the Remotes section on the RepositorySettings
page.
@jcansdale

Copy link
Copy Markdown
CollaboratorAuthor

@jnm2 thanks for the review! I think I've implemented all of your suggestions.

Comment threadsrc/GitHub.Services.Vssdk/Services/TippingService.cs Outdated
@jcansdale

jcansdale commented Nov 21, 2018

Copy link
Copy Markdown
CollaboratorAuthor
2018-11-21 20:09:58.160 [05624] EROR [25] PullRequestStatusBarManager System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at GitHub.InlineReviews.Services.PullRequestStatusBarManager.NoRemoteOriginCallout() in C:\Source\github.com\github\VisualStudio\src\GitHub.InlineReviews\Services\PullRequestStatusBarManager.cs:line 115
at GitHub.InlineReviews.Services.PullRequestStatusBarManager.<RefreshCurrentSession>d__10.MoveNext() in C:\Source\github.com\github\VisualStudio\src\GitHub.InlineReviews\Services\PullRequestStatusBarManager.cs:line 91
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
at GitHub.InlineReviews.Services.PullRequestStatusBarManager.NoRemoteOriginCallout() in C:\Source\github.com\github\VisualStudio\src\GitHub.InlineReviews\Services\PullRequestStatusBarManager.cs:line 115
at GitHub.InlineReviews.Services.PullRequestStatusBarManager.<RefreshCurrentSession>d__10.MoveNext() in C:\Source\github.com\github\VisualStudio\src\GitHub.InlineReviews\Services\PullRequestStatusBarManager.cs:line 91<---

Update: fixed. A strange issue with GetService(typeof(ITippingService)) coming back null on Visual Studio 2015 😕

@jcansdale

Copy link
Copy Markdown
CollaboratorAuthor
2018-11-21 20:06:36.670 [05624] DBUG [29] TeamExplorerContext ActiveRepository changed to https://github.com/jcansdale/EmojiVS @ C:\Source\github.com\jbevain\EmojiVS
2018-11-21 20:07:04.295 [05624] DBUG [09] VSGitExt IGitExt.ActiveRepositories (#18029106) returned ["C:\\Source\\github.com\\jbevain\\EmojiVS"]
2018-11-21 20:07:04.328 [05624] EROR [09] VSGitExt Error refreshing repositories
LibGit2Sharp.LockedFileException: Failed open - 'C:/Source/github.com/jbevain/EmojiVS/.git/config' is locked: The process cannot access the file because it is being used by another process.
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Proxy.git_remote_lookup(RepositoryHandle repo, String name, Boolean throwsIfNotFound)
at LibGit2Sharp.RemoteCollection.RemoteForName(String name, Boolean shouldThrowIfNotFound)
at LibGit2Sharp.RemoteCollection.get_Item(String name)
at GitHub.Services.GitService.HasRemotesButNoOrigin(IRepository repo) in C:\Source\github.com\github\VisualStudio\src\GitHub.Exports\Services\GitService.cs:line 143
at GitHub.Services.GitService.CreateLocalRepositoryModel(String localPath) in C:\Source\github.com\github\VisualStudio\src\GitHub.Exports\Services\GitService.cs:line 49
at GitHub.VisualStudio.Base.VSGitExt.<RefreshActiveRepositories>b__9_1(IGitRepositoryInfo x) in C:\Source\github.com\github\VisualStudio\src\GitHub.TeamFoundation.14\Services\VSGitExt.cs:line 115
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at GitHub.VisualStudio.Base.VSGitExt.RefreshActiveRepositories() in C:\Source\github.com\github\VisualStudio\src\GitHub.TeamFoundation.14\Services\VSGitExt.cs:line 115
2018-11-21 20:07:04.375 [05624] DBUG [09] VSGitExt ActiveRepositories changed to []

ServiceProviderExports.GetService<TippingService>() was returning null
on Visual Studio 2015 so, fall back to using new TippingService(...).
Don't let any exceptions here impact other functionality.
Use the COM Guid rather than simple name to locate interface.
The RequestCalloutDisplay method that takes commandOption is only
available on VS 2017+.

@grokysgrokys 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.

Looking great! Just one thing, and a question.

Comment threadsrc/GitHub.VisualStudio.UI/Views/GitHubPane/NoRemoteOriginView.xaml Outdated
Comment threadsrc/GitHub.VisualStudio/GitHubPackage.cs
Add RepositoriesMustHaveRemoteOriginHowToFix resource string.
Add Margin="4" to TextBlocks to make them appear as paragraphs.
@jcansdale
jcansdale merged commit 6eda710 into masterNov 29, 2018
@jcansdale
jcansdale deleted the fixes/1729-warn-when-no-origin branch November 29, 2018 10:18
Sign up for freeto 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.

Repository not recognized as being from GitHub if there no remote named "origin"

3 participants

@jcansdale@grokys@jnm2