From 706fddfff6355cc88e8762930276746affeaee3a Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Mon, 4 Mar 2019 11:56:04 -0800 Subject: [PATCH 1/3] Correctly support language filter in repo search --- Octokit.Tests/Models/SearchRepositoryRequestTests.cs | 8 ++++++++ Octokit/Models/Request/SearchRepositoriesRequest.cs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs index e49d9d151b..7397783256 100644 --- a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs +++ b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs @@ -25,5 +25,13 @@ public void SortNotSpecifiedByDefault() Assert.True(string.IsNullOrWhiteSpace(request.Sort)); Assert.False(request.Parameters.ContainsKey("sort")); } + + [Fact] + public void LanguageUsesParameterTranslation() + { + var request = new SearchRepositoriesRequest() { Language = Language.CPlusPlus }; + var result = request.MergedQualifiers(); + Assert.Contains(result, x => string.Equals(x, "language:C++")); + } } } diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index f4101dde1b..dc48711197 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -148,7 +148,7 @@ public override IReadOnlyList MergedQualifiers() if (Language != null) { - parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language)); + parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter())); } if (User.IsNotBlank()) From 435c829a5367e573afd21fd4b02bb0832f2ceff5 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Mon, 4 Mar 2019 13:19:53 -0800 Subject: [PATCH 2/3] Fix failing client test --- Octokit.Tests/Clients/SearchClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index ace933ddc1..f8262ce64b 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -463,7 +463,7 @@ public void TestingTheLangaugeQualifier() request.Language = Language.Ruby; client.SearchRepo(request); connection.Received().Get(Arg.Is(u => u.ToString() == "search/repositories"), - Arg.Is>(d => d["q"] == "github+language:Ruby")); + Arg.Is>(d => d["q"] == "github+language:ruby")); } [Fact] From 6c8d2e2e2b4c2533344d55943412e4e6d3e81963 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Sun, 10 Mar 2019 18:03:22 -0700 Subject: [PATCH 3/3] Use the correct language code for C++ --- Octokit.Tests/Models/SearchRepositoryRequestTests.cs | 2 +- Octokit/Models/Request/SearchRepositoriesRequest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs index 7397783256..c01c7288a0 100644 --- a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs +++ b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs @@ -31,7 +31,7 @@ public void LanguageUsesParameterTranslation() { var request = new SearchRepositoriesRequest() { Language = Language.CPlusPlus }; var result = request.MergedQualifiers(); - Assert.Contains(result, x => string.Equals(x, "language:C++")); + Assert.Contains(result, x => string.Equals(x, "language:cpp")); } } } diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index dc48711197..2c390ab557 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -460,7 +460,7 @@ public enum Language ColdFusion, CommonLisp, Coq, - [Parameter(Value = "C++")] + [Parameter(Value = "cpp")] CPlusPlus, [Parameter(Value = "CSharp")] CSharp,