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

Commit 5019370

Browse files
committed
Detect repository home with no description
1 parent e900d7d commit 5019370

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/GitHub.App/Services/GitHubContextService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class GitHubContextService
2828

2929
static readonly string path = $"^{repo}/(?<path>[^ ]+)";
3030

31-
static readonly Regex windowTitleRepositoryRegex = new Regex($"^(GitHub - )?{owner}/{repo}: ", RegexOptions.Compiled);
31+
static readonly Regex windowTitleRepositoryRegex = new Regex($"^(GitHub - )?{owner}/{repo}(: .*)? - ", RegexOptions.Compiled);
3232
static readonly Regex windowTitleBranchRegex = new Regex($"^(GitHub - )?{owner}/{repo} at {branch} ", RegexOptions.Compiled);
3333
static readonly Regex windowTitlePullRequestRegex = new Regex($" · Pull Request #{pull} · {owner}/{repo}( · GitHub)? - ", RegexOptions.Compiled);
3434
static readonly Regex windowTitleIssueRegex = new Regex($" · Issue #{issue} · {owner}/{repo}( · GitHub)? - ", RegexOptions.Compiled);

test/GitHub.App.UnitTests/Services/GitHubContextServiceTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ public void PullRequest(string windowTitle, int expectPullRequest)
268268

269269
[TestCase("Consider adding C# code style preferences to editorconfig · Issue #1750 · github/VisualStudio - Google Chrome", 1750)]
270270
[TestCase("Scrape browser titles · Issue #4 · jcansdale/VisualStudio · GitHub - Mozilla Firefox", 4, Description = "Firefox")]
271-
272271
public void Issue(string windowTitle, int expectIssue)
273272
{
274273
var target = new GitHubContextService();
@@ -292,14 +291,16 @@ public void Path(string windowTitle, string expectPath)
292291

293292
[TestCase("jcansdale/VisualStudio: GitHub Extension for Visual Studio - Google Chrome", "jcansdale", "VisualStudio", Description = "Chrome")]
294293
[TestCase("GitHub - jcansdale/VisualStudio: GitHub Extension for Visual Studio - Mozilla Firefox", "jcansdale", "VisualStudio", Description = "Firefox")]
294+
[TestCase("jcansdale/GhostAssemblies - Google Chrome", "jcansdale", "GhostAssemblies", Description = "No description, Chrome")]
295+
[TestCase("GitHub - jcansdale/GhostAssemblies - Mozilla Firefox", "jcansdale", "GhostAssemblies", Description = "No description, Firefox")]
295296
public void RepositoryHome(string windowTitle, string expectOwner, string expectRepositoryName)
296297
{
297298
var target = new GitHubContextService();
298299

299300
var context = target.FindContextFromWindowTitle(windowTitle);
300301

301-
Assert.That(context.Owner, Is.EqualTo(expectOwner));
302-
Assert.That(context.RepositoryName, Is.EqualTo(expectRepositoryName));
302+
Assert.That(context?.Owner, Is.EqualTo(expectOwner));
303+
Assert.That(context?.RepositoryName, Is.EqualTo(expectRepositoryName));
303304
}
304305
}
305306
}

0 commit comments

Comments
 (0)