From d03881d12046be43f4b14db05c97d637ae824c98 Mon Sep 17 00:00:00 2001 From: Jose de Jesus Medina Rios Date: Thu, 1 Oct 2020 17:21:38 -0700 Subject: [PATCH 1/2] added license search --- .../Request/SearchRepositoriesRequest.cs | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index f674fa9168..bcc4be70d9 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -112,6 +112,12 @@ public IEnumerable In /// public DateRange Updated { get; set; } + /// + /// Filters repositoreis based on license + /// https://help.github.com/articles/searching-repositories#search-by-license + /// + public RepoSearchLicense? License { get; set; } + /// /// Filters whether archived repositories should be included (true) or not (false). /// @@ -171,6 +177,11 @@ public override IReadOnlyList MergedQualifiers() parameters.Add(string.Format(CultureInfo.InvariantCulture, "archived:{0}", Archived.ToString().ToLower())); } + if (License != null) + { + parameters.Add(string.Format(CultureInfo.InvariantCulture, "license:{0}", License.ToParameter())); + } + return parameters; } @@ -863,6 +874,97 @@ public enum Language #pragma warning restore 1591 } + /// + /// Licenses than can be searched on GitHub + /// + public enum RepoSearchLicense + { + [Parameter(Value = "afl-3.0")] + AcademicFree_3_0, + [Parameter(Value = "apache-2.0")] + Apache_2_0, + [Parameter(Value = "artistic-2.0")] + Artistic_2_0, + [Parameter(Value = "bsl-1.0")] + BoostSoftware_1_0, + [Parameter(Value = "0bsd")] + BSD0Clause, + [Parameter(Value = "bsd-2-clause")] + BSD2Clause, + [Parameter(Value = "bsd-3-clause")] + BSD3Clause, + [Parameter(Value = "bsd-3-clause-clear")] + BSD3ClauseClear, + [Parameter(Value = "bsd-4-clause")] + BSD4Clause, + [Parameter(Value = "cc")] + CreativeCommons, + [Parameter(Value = "cc0-1.0")] + CreativeCommonsZero_1_0, + [Parameter(Value = "cc-by-4.0")] + CreativeCommonsAtrribution_4_0, + [Parameter(Value = "cc-by-sa-4.0")] + CreativeCommonsAttributionShareAlike_4_0, + [Parameter(Value = "cecill-2.1")] + CeCILL_2_1, + [Parameter(Value = "wtfpl")] + DoWhatTheFYouWant, + [Parameter(Value = "ecl-2.0")] + EducationalCommunity_2_0, + [Parameter(Value = "epl-1.0")] + EclipsePublic_1_0, + [Parameter(Value = "epl-2.0")] + EclipsePublic_2_0, + [Parameter(Value = "eupl-1.1")] + EuropeanUnionPublic_1_1, + [Parameter(Value = "eupl-1.2")] + EuropeanUnionPublic_1_2, + [Parameter(Value = "agpl-3.0")] + GNUAfferoGeneralPublic_3_0, + [Parameter(Value = "gpl")] + GNUGeneralPublic, + [Parameter(Value = "gpl-2.0")] + GNUGeneralPublic_2_0, + [Parameter(Value = "gpl-3.0")] + GNUGeneralPublic_3_0, + [Parameter(Value = "lgpl")] + GNULesserGeneralPublic, + [Parameter(Value = "lgpl-2.1")] + GNULesserGeneralPublic_2_1, + [Parameter(Value = "lgpl-3.0")] + GNULesserGeneralPublic_3_0, + [Parameter(Value = "isc")] + ISC, + [Parameter(Value = "lppl-1.3c")] + LatexProjectPublic, + [Parameter(Value = "ms-pl")] + MicrosoftPublic, + [Parameter(Value = "ms-rl")] + MicrosoftReciprocal, + [Parameter(Value = "mit")] + MIT, + [Parameter(Value = "mpl-2.0")] + MozillaPublic_2_0, + [Parameter(Value = "odbl-1.0")] + ODCOpenDatabase, + [Parameter(Value = "osl-3.0")] + OpenSoftware_3_0, + [Parameter(Value = "postgresql")] + PostgreseSQL, + [Parameter(Value = "ofl-1.1")] + SILOpenFont, + [Parameter(Value = "upl-1.0")] + UniversalPermissive, + [Parameter(Value = "ncsa")] + NSCAOpenSource, + [Parameter(Value = "unlicense")] + TheUnlicense, + [Parameter(Value = "vim")] + Vim, + [Parameter(Value = "zlib")] + ZLib + } + /// /// sorting repositories by any of below /// https://help.github.com/articles/searching-repositories#sorting From 23198a89bd340c43fec7940aed97a00fc833432c Mon Sep 17 00:00:00 2001 From: Dagizmo Date: Thu, 1 Oct 2020 21:18:42 -0700 Subject: [PATCH 2/2] Fix typos add test --- Octokit.Tests/Models/SearchRepositoryRequestTests.cs | 8 ++++++++ Octokit/Models/Request/SearchRepositoriesRequest.cs | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs index ebeda46282..e9441131d6 100644 --- a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs +++ b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs @@ -33,5 +33,13 @@ public void LanguageUsesParameterTranslation() var result = request.MergedQualifiers(); Assert.Contains(result, x => string.Equals(x, "language:\"cpp\"")); } + + [Fact] + public void LicenseUsesParameterTranslation() + { + var request = new SearchRepositoriesRequest() { License = RepoSearchLicense.Apache_2_0 }; + var result = request.MergedQualifiers(); + Assert.Contains(result, x => string.Equals(x, "license:apache-2.0")); + } } } diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index bcc4be70d9..bb8fb0978d 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -113,7 +113,7 @@ public IEnumerable In public DateRange Updated { get; set; } /// - /// Filters repositoreis based on license + /// Filters repositories based on license /// https://help.github.com/articles/searching-repositories#search-by-license /// public RepoSearchLicense? License { get; set; } @@ -512,7 +512,7 @@ public override string ToString() } /// - /// lanuages that can be searched on in github + /// Languages that can be searched on in GitHub /// https://help.github.com/articles/searching-repositories#languages /// public enum Language @@ -876,6 +876,7 @@ public enum Language /// /// Licenses than can be searched on GitHub + /// https://help.github.com/articles/searching-repositories#search-by-license /// public enum RepoSearchLicense {