From 2c0f1b5dce97d37169d2f290c70c625f3a5f0c2c Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 29 Nov 2022 12:20:52 +0600 Subject: [PATCH 1/3] add islocker filter to SeachIssuesRequest --- .../Clients/SearchClientTests.cs | 22 +++++++++++++++++++ .../Models/SearchIssuesRequestTests.cs | 11 ++++++++++ Octokit/Models/Request/SearchIssuesRequest.cs | 6 ++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index c64d6a02f2..9123ecdc3c 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -281,6 +281,28 @@ public async Task SearchForAllIssuesUsingTerm() Assert.NotEmpty(openedIssues); } + [IntegrationTest] + public async Task SearchForLockedUnlockedIssues() + { + + var lockedIssuesRequest = new SearchIssuesRequest(); + lockedIssuesRequest.Repos.Add("octokit", "octokit.net"); + lockedIssuesRequest.Is = new List { IssueIsQualifier.Issue, IssueIsQualifier.Locked }; + + var lockedIssues = await _gitHubClient.Search.SearchIssues(lockedIssuesRequest); + + var unlockedIssuesRequest = new SearchIssuesRequest(); + + unlockedIssuesRequest.Repos.Add("octokit", "octokit.net"); + unlockedIssuesRequest.Is = new List { IssueIsQualifier.Issue, IssueIsQualifier.Unlocked }; + + + var unlockedIssues = await _gitHubClient.Search.SearchIssues(unlockedIssuesRequest); + + Assert.All(lockedIssues.Items, i => Assert.True(i.Locked)); + Assert.All(unlockedIssues.Items, i => Assert.False(i.Locked)); + } + [IntegrationTest] public async Task SearchForMergedPullRequests() { diff --git a/Octokit.Tests/Models/SearchIssuesRequestTests.cs b/Octokit.Tests/Models/SearchIssuesRequestTests.cs index 9227e7a8e0..dfa5e55a69 100644 --- a/Octokit.Tests/Models/SearchIssuesRequestTests.cs +++ b/Octokit.Tests/Models/SearchIssuesRequestTests.cs @@ -170,6 +170,17 @@ public void HandlesIsAttributeCorrectly() Assert.Contains("is:pr", request.MergedQualifiers()); } + [Fact] + public void HandlesIsLockedUnlockedAttributeCorrectly() + { + var request = new SearchIssuesRequest("test"); + Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("is:")); + + request.Is = new List { IssueIsQualifier.Locked, IssueIsQualifier.Unlocked }; + Assert.Contains("is:locked", request.MergedQualifiers()); + Assert.Contains("is:unlocked", request.MergedQualifiers()); + } + [Fact] public void HandlesStatusAttributeCorrectly() { diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index acb33c6f47..391e04130a 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -489,7 +489,11 @@ public enum IssueIsQualifier [Parameter(Value = "private")] Private, [Parameter(Value = "public")] - Public + Public, + [Parameter(Value = "locked")] + Locked, + [Parameter(Value = "unlocked")] + Unlocked } public enum IssueNoMetadataQualifier From 8491bf72f0cccdba12a6e8668532a4ef964cf02e Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 29 Nov 2022 12:49:44 +0600 Subject: [PATCH 2/3] update docs --- docs/search.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/search.md b/docs/search.md index 1c3e1c7f90..4bc41a6121 100644 --- a/docs/search.md +++ b/docs/search.md @@ -61,6 +61,14 @@ request.Involves = "terrajobst"; request.State = ItemState.All; // or to just search closed issues request.State = ItemState.Closed; + +// you can filter by the is qualifier +// the enum IssueIsQualifier contains the supported values +// here is how you will can filter with issue and locked +request.Is = new List { + IssueIsQualifier.Issue, + IssueIsQualifier.Locked +}; ``` There's other options available to control how the results are returned: From 0f3fc42ff621ba9e5bc1c90c18f3a511cc36acb8 Mon Sep 17 00:00:00 2001 From: notauserx <82922717+notauserx@users.noreply.github.com> Date: Wed, 30 Nov 2022 08:36:24 +0600 Subject: [PATCH 3/3] Update docs/search.md with review suggestions Co-authored-by: Keegan Campbell --- docs/search.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/search.md b/docs/search.md index 4bc41a6121..95dfdc218b 100644 --- a/docs/search.md +++ b/docs/search.md @@ -62,9 +62,9 @@ request.State = ItemState.All; // or to just search closed issues request.State = ItemState.Closed; -// you can filter by the is qualifier +// you can filter by the "Is" qualifier // the enum IssueIsQualifier contains the supported values -// here is how you will can filter with issue and locked +// you can filter for locked issues like this: request.Is = new List { IssueIsQualifier.Issue, IssueIsQualifier.Locked