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

Commit 07fb7bd

Browse files
authored
Merge pull request #1700 from jcansdale/fixes/1692-fix-fork-View-on-GitHub
Fix `View on GitHub` when on fork repository
2 parents 947d8b6 + 103ecdb commit 07fb7bd

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using System.Collections.Generic;
34
using System.ComponentModel.Composition;
45
using System.IO;
@@ -328,7 +329,7 @@ public async Task InitializeAsync(
328329
LocalRepository = localRepository;
329330
RemoteRepositoryOwner = owner;
330331
Number = number;
331-
WebUrl = LocalRepository.CloneUrl.ToRepositoryUrl().Append("pull/" + number);
332+
WebUrl = localRepository.CloneUrl.ToRepositoryUrl(owner).Append("pull/" + number);
332333
modelService = await modelServiceFactory.CreateAsync(connection);
333334

334335
await Refresh();

src/GitHub.VisualStudio/Views/GitHubPane/PullRequestDetailView.xaml.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ public PullRequestDetailView()
4141
void DoOpenOnGitHub()
4242
{
4343
var browser = VisualStudioBrowser;
44-
var cloneUrl = ViewModel.LocalRepository.CloneUrl;
45-
var url = ToPullRequestUrl(cloneUrl.Host, ViewModel.RemoteRepositoryOwner, ViewModel.LocalRepository.Name, ViewModel.Model.Number);
46-
browser.OpenUrl(url);
47-
}
48-
49-
static Uri ToPullRequestUrl(string host, string owner, string repositoryName, int number)
50-
{
51-
var url = string.Format(CultureInfo.InvariantCulture, "https://{0}/{1}/{2}/pull/{3}", host, owner, repositoryName, number);
52-
return new Uri(url);
44+
browser.OpenUrl(ViewModel.WebUrl);
5345
}
5446

5547
void OpenHyperlink(object sender, ExecutedRoutedEventArgs e)

0 commit comments

Comments
 (0)