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

Commit 030e2da

Browse files
committed
Add warnings when blob URL file can't be found
Warn when blob can't be found in the repository. Warn when the working file is different blob URL file.
1 parent b47abfd commit 030e2da

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/GitHub.App/Services/GitHubContextService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Text;
44
using System.Linq;
55
using System.Windows;
6+
using System.Globalization;
67
using System.Threading.Tasks;
78
using System.Collections.Generic;
89
using System.ComponentModel.Composition;
@@ -75,13 +76,19 @@ public void TryNavigateToContext(string repositoryDir, GitHubContext context)
7576
{
7677
if (context?.LinkType == LinkType.Blob)
7778
{
78-
// Navigate to file for /blob/ type URLs
7979
var (commitish, path, commitSha) = ResolveBlob(repositoryDir, context);
80+
if (commitish == null && path == null)
81+
{
82+
var message = string.Format(CultureInfo.CurrentCulture, Resources.CouldntFindCorrespondingFile, context.Url);
83+
vsServices.ShowMessageBoxInfo(message);
84+
return;
85+
}
8086

8187
var hasChanges = HasChangesInWorkingDirectory(repositoryDir, commitish, path);
8288
if (hasChanges)
8389
{
84-
vsServices.ShowMessageBoxInfo(Resources.ChangesInWorkingDirectoryMessage + Environment.NewLine + commitish);
90+
var message = string.Format(CultureInfo.CurrentCulture, Resources.ChangesInWorkingDirectoryMessage, commitish);
91+
vsServices.ShowMessageBoxInfo(message);
8592
}
8693

8794
TryOpenFile(repositoryDir, context);

src/GitHub.Resources/Resources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.Resources/Resources.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ https://git-scm.com/download/win</value>
810810
<value>There is no active repository to navigate</value>
811811
</data>
812812
<data name="ChangesInWorkingDirectoryMessage" xml:space="preserve">
813-
<value>This file has changed since the permalink was created</value>
813+
<value>The working file is different to the file at '{0}'. Please checkout the corresponding branch, pull request or commit.</value>
814814
</data>
815815
<data name="DifferentRepositoryMessage" xml:space="preserve">
816816
<value>Please open the repository '{0}' and try again</value>
@@ -845,4 +845,7 @@ https://git-scm.com/download/win</value>
845845
<data name="RepositoriesMustHaveRemoteOriginHowToFix" xml:space="preserve">
846846
<value>Please rename one of your existing remotes to 'origin' or add a new remote named 'origin' and fetch. This can be done from the command line or by clicking the button below.</value>
847847
</data>
848+
<data name="CouldntFindCorrespondingFile" xml:space="preserve">
849+
<value>Couldn't find file corresponding to '{0}' in the repository. Please do a 'git fetch' or checkout the target pull request.</value>
850+
</data>
848851
</root>

0 commit comments

Comments
 (0)