diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index 2ade8ef144..47c2a7600e 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -738,6 +738,29 @@ public void TestingTheTopicsQualifierWithTwoOrLessTopics() Assert.Contains("topics:<=2", request.MergedQualifiers()); } + + [Fact] + public void TestingTheCustomPropertiesQualifier() + { + var request = new SearchRepositoriesRequest("github"); + request.CustomProperties = new Dictionary { { "custom", "value" } }; + + Assert.Contains("props.custom:value", request.MergedQualifiers()); + } + + [Fact] + public void TestingMultipleCustomPropertiesQualifiers() + { + var request = new SearchRepositoriesRequest("github"); + request.CustomProperties = new Dictionary { + { "custom_one", "value_one" }, + { "custom_two", "value_two" } + }; + + var merged = request.MergedQualifiers(); + Assert.Contains("props.custom_one:value_one", merged); + Assert.Contains("props.custom_two:value_two", merged); + } } public class TheSearchIssuesMethod diff --git a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs index e9441131d6..d1ed6e552f 100644 --- a/Octokit.Tests/Models/SearchRepositoryRequestTests.cs +++ b/Octokit.Tests/Models/SearchRepositoryRequestTests.cs @@ -1,4 +1,4 @@ -using System; +using System.Collections.Generic; using Octokit; using Octokit.Tests.Helpers; using Xunit; @@ -41,5 +41,13 @@ public void LicenseUsesParameterTranslation() var result = request.MergedQualifiers(); Assert.Contains(result, x => string.Equals(x, "license:apache-2.0")); } + + [Fact] + public void CustomPropertiesPrependsProps() + { + var request = new SearchRepositoriesRequest() { CustomProperties = new Dictionary { { "name", "value" } } }; + var result = request.MergedQualifiers(); + Assert.Contains(result, x => string.Equals(x, "props.name:value")); + } } } diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 3a13b9dba3..114962bda4 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -10,7 +10,7 @@ namespace Octokit { /// /// Searching Repositories - /// http://developer.github.com/v3/search/#search-repositories + /// https://docs.github.com/rest/search/search#search-repositories /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class SearchRepositoriesRequest : BaseSearchRequest @@ -33,7 +33,7 @@ public SearchRepositoriesRequest(string term) } /// - /// For https://help.github.com/articles/searching-repositories#sorting + /// For https://docs.github.com/search-github/getting-started-with-searching-on-github/sorting-search-results /// Optional Sort field. One of stars, forks, or updated. If not provided, results are sorted by best match. /// public RepoSearchSort? SortField { get; set; } @@ -46,9 +46,9 @@ public override string Sort private IEnumerable _inQualifier; /// - /// The in qualifier limits what fields are searched. With this qualifier you can restrict the search to just the repository name, description, README, or any combination of these. + /// The in qualifier limits what fields are searched. With this qualifier you can restrict the search to just the repository name, description, README, or any combination of these. /// Without the qualifier, only the name and description are searched. - /// https://help.github.com/articles/searching-repositories#search-in + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-repository-name-description-or-contents-of-the-readme-file /// public IEnumerable In { @@ -65,74 +65,83 @@ public IEnumerable In /// /// Filters repositories based on the number of forks, and/or whether forked repositories should be included in the results at all. - /// https://help.github.com/articles/searching-repositories#forks + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-number-of-forks /// public Range Forks { get; set; } /// /// Filters repositories based whether forked repositories should be included in the results at all. /// Defaults to ExcludeForks - /// https://help.github.com/articles/searching-repositories#forks + /// https://docs.github.com/search-github/searching-on-github/searching-in-forks /// public ForkQualifier? Fork { get; set; } /// /// The size qualifier finds repository's that match a certain size (in kilobytes). - /// https://help.github.com/articles/searching-repositories#size + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-repository-size /// public Range Size { get; set; } /// /// Searches repositories based on the language they’re written in. - /// https://help.github.com/articles/searching-repositories#languages + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-language /// public Language? Language { get; set; } /// /// Searches repositories based on the number of stars. - /// https://help.github.com/articles/searching-repositories#stars + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-number-of-stars /// public Range Stars { get; set; } /// /// Limits searches to a specific user or repository. - /// https://help.github.com/articles/searching-repositories#users-organizations-and-repositories + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-within-a-users-or-organizations-repositories /// public string User { get; set; } /// /// Filters repositories based on times of creation. - /// https://help.github.com/articles/searching-repositories#created-and-last-updated + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-when-a-repository-was-created-or-last-updated /// public DateRange Created { get; set; } /// /// Filters repositories based on when they were last updated. - /// https://help.github.com/articles/searching-repositories#created-and-last-updated + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-when-a-repository-was-created-or-last-updated /// public DateRange Updated { get; set; } /// /// Filters repositories based on license - /// https://help.github.com/articles/searching-repositories#search-by-license + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-license /// public RepoSearchLicense? License { get; set; } /// /// Filters whether archived repositories should be included (true) or not (false). + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-based-on-whether-a-repository-is-archived /// public bool? Archived { get; set; } /// /// Filters on whether repositories are tagged with the given topic. + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-topic /// public string Topic { get; set; } /// /// Filters on the number of topics that a repository is associated with. + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-number-of-topics /// public Range Topics { get; set; } + /// + /// Filters on repositories based on custom properties. + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-based-on-repository-custom-property + /// + public IDictionary CustomProperties { get; set; } + public override IReadOnlyList MergedQualifiers() { var parameters = new List(); @@ -200,6 +209,13 @@ public override IReadOnlyList MergedQualifiers() { parameters.Add(string.Format(CultureInfo.InvariantCulture, "license:{0}", License.ToParameter())); } + if (CustomProperties != null) + { + foreach (var customProperty in CustomProperties) + { + parameters.Add(string.Format(CultureInfo.InvariantCulture, "props.{0}:{1}", customProperty.Key, customProperty.Value)); + } + } return parameters; } @@ -214,8 +230,8 @@ internal string DebuggerDisplay } /// - /// https://help.github.com/articles/searching-repositories#search-in - /// The in qualifier limits what fields are searched. With this qualifier you can restrict the search to just the + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-repository-name-description-or-contents-of-the-readme-file + /// The in qualifier limits what fields are searched. With this qualifier you can restrict the search to just the /// repository name, description, README, or any combination of these. /// public enum InQualifier @@ -226,6 +242,9 @@ public enum InQualifier [Parameter(Value = "description")] Description, + [Parameter(Value = "topics")] + Topics, + [Parameter(Value = "readme")] Readme } @@ -256,7 +275,7 @@ public Range(int minSize, int maxSize) } /// - /// Matches repositories with regards to the size + /// Matches repositories with regards to the size /// We will use the to see what operator will be applied to the size qualifier /// public Range(int size, SearchQualifierOperator op) @@ -323,7 +342,7 @@ public override string ToString() /// /// helper class in generating the date range values for the date qualifier e.g. - /// https://help.github.com/articles/searching-repositories#created-and-last-updated + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-when-a-repository-was-created-or-last-updated /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class DateRange @@ -532,7 +551,7 @@ public override string ToString() /// /// Languages that can be searched on in GitHub - /// https://help.github.com/articles/searching-repositories#languages + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-language /// public enum Language { @@ -897,7 +916,7 @@ public enum Language /// /// Licenses than can be searched on GitHub - /// https://help.github.com/articles/searching-repositories#search-by-license + /// https://docs.github.com/search-github/searching-on-github/searching-for-repositories#search-by-license /// public enum RepoSearchLicense { @@ -989,7 +1008,8 @@ public enum RepoSearchLicense /// /// sorting repositories by any of below - /// https://help.github.com/articles/searching-repositories#sorting + /// https://docs.github.com/rest/search/search?#search-repositories + /// https://docs.github.com/search-github/getting-started-with-searching-on-github/sorting-search-results /// public enum RepoSearchSort { @@ -1004,6 +1024,11 @@ public enum RepoSearchSort [Parameter(Value = "forks")] Forks, /// + /// search by number of help-wanted-issues + /// + [Parameter(Value = "help-wanted-issues")] + HelpWantedIssues, + /// /// search by last updated /// [Parameter(Value = "updated")] @@ -1011,7 +1036,7 @@ public enum RepoSearchSort } /// - /// https://help.github.com/articles/searching-repositories#forks + /// https://docs.github.com/search-github/searching-on-github/searching-in-forks /// Specifying whether forked repositories should be included in results or not. /// public enum ForkQualifier