diff --git a/src/GitHub.Exports/Primitives/UriString.cs b/src/GitHub.Exports/Primitives/UriString.cs index 4ff21457b1..679201e34e 100644 --- a/src/GitHub.Exports/Primitives/UriString.cs +++ b/src/GitHub.Exports/Primitives/UriString.cs @@ -51,7 +51,7 @@ public UriString(string uriString) : base(NormalizePath(uriString)) } } - static UriString ToUriString(Uri uri) + public static UriString ToUriString(Uri uri) { return uri == null ? null : new UriString(uri.ToString()); } diff --git a/src/GitHub.Exports/Services/Services.cs b/src/GitHub.Exports/Services/Services.cs index 97c15f24d9..63088d9f04 100644 --- a/src/GitHub.Exports/Services/Services.cs +++ b/src/GitHub.Exports/Services/Services.cs @@ -116,7 +116,7 @@ public static T GetExportedValue(this IServiceProvider serviceProvider) } } - public static Uri GetRepoUrlFromSolution(IVsSolution solution) + public static UriString GetRepoUrlFromSolution(IVsSolution solution) { string solutionDir, solutionFile, userFile; if (!ErrorHandler.Succeeded(solution.GetSolutionInfo(out solutionDir, out solutionFile, out userFile))) @@ -128,7 +128,7 @@ public static Uri GetRepoUrlFromSolution(IVsSolution solution) return null; using (var repo = new Repository(repoPath)) { - return GetUriFromRepository(repo)?.ToRepositoryUrl(); + return repo.GetUri(); } } @@ -145,7 +145,12 @@ public static Repository GetRepoFromSolution(this IVsSolution solution) return new Repository(repoPath); } - public static UriString GetUriFromRepository(Repository repo) + public static UriString GetUri(this Repository repo) + { + return UriString.ToUriString(GetUriFromRepository(repo)?.ToRepositoryUrl()); + } + + static UriString GetUriFromRepository(Repository repo) { return repo ?.Network diff --git a/src/GitHub.VisualStudio/Base/TeamExplorerItemBase.cs b/src/GitHub.VisualStudio/Base/TeamExplorerItemBase.cs index ec14926bbe..a0a1aa22df 100644 --- a/src/GitHub.VisualStudio/Base/TeamExplorerItemBase.cs +++ b/src/GitHub.VisualStudio/Base/TeamExplorerItemBase.cs @@ -48,8 +48,8 @@ protected virtual void RepoChanged() if (repo != null) { var gitRepo = repo.GetRepoFromIGit(); - var uri = Services.GetUriFromRepository(gitRepo); - var name = uri.RepositoryName; + var uri = gitRepo?.GetUri(); + var name = uri?.RepositoryName; if (name != null) { ActiveRepoUri = uri;