Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to search Tags #798

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions NGitLab.Tests/TagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ public async Task Test_can_tag_a_project()
Assert.That(tagsClient.All.FirstOrDefault(x => string.Equals(x.Name, "v0.5", StringComparison.Ordinal)), Is.Null);
}

[NGitLabRetry]
[TestCase("^v0.5", 1)]
[TestCase("^v0", 2)]
[TestCase("^v1", 0)]
[TestCase("v1", 0)]
louis-z marked this conversation as resolved.
Show resolved Hide resolved
public async Task SearchTags(string search, int expectedCount)
{
// Arrange
using var context = await GitLabTestContext.CreateAsync();
var project = context.CreateProject(initializeWithCommits: true);
var tagClient = context.Client.GetRepository(project.Id).Tags;

tagClient.Create(new TagCreate
{
Name = "v0.5",
Message = "Test message",
Ref = project.DefaultBranch,
});

tagClient.Create(new TagCreate
{
Name = "v0.6",
Message = "Test second message",
Ref = project.DefaultBranch,
});

var tagFetched = tagClient.GetAsync(new TagQuery { Search = search });
Assert.That(tagFetched.Count(), Is.EqualTo(expectedCount));
}

[NGitLabRetry]
[TestCase("v0.5", true)]
[TestCase("v0.6", false)]
Expand Down
1 change: 1 addition & 0 deletions NGitLab/Impl/TagClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public GitLabCollectionResponse<Tag> GetAsync(TagQuery query)
url = Utils.AddParameter(url, "order_by", query.OrderBy);
url = Utils.AddParameter(url, "sort", query.Sort);
url = Utils.AddParameter(url, "per_page", query.PerPage);
url = Utils.AddParameter(url, "search", query.Search);
}

return _api.Get().GetAllAsync<Tag>(url);
Expand Down
2 changes: 2 additions & 0 deletions NGitLab/Models/TagQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public class TagQuery
public string Sort { get; set; }

public int? PerPage { get; set; }

public string Search { get; set; }
}
2 changes: 2 additions & 0 deletions NGitLab/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3812,6 +3812,8 @@ NGitLab.Models.TagQuery.OrderBy.get -> string
NGitLab.Models.TagQuery.OrderBy.set -> void
NGitLab.Models.TagQuery.PerPage.get -> int?
NGitLab.Models.TagQuery.PerPage.set -> void
NGitLab.Models.TagQuery.Search.get -> string
NGitLab.Models.TagQuery.Search.set -> void
NGitLab.Models.TagQuery.Sort.get -> string
NGitLab.Models.TagQuery.Sort.set -> void
NGitLab.Models.TagQuery.TagQuery() -> void
Expand Down