Skip to content

Commit a23abbd

Browse files
committed
Allow the sort field and sort direction to be configurable
1 parent 6450304 commit a23abbd

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

src/GitReleaseManager.Core/Configuration/CreateConfig.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.ComponentModel;
22
using GitReleaseManager.Core.Attributes;
3+
using GitReleaseManager.Core.Model;
34
using YamlDotNet.Serialization;
45

56
namespace GitReleaseManager.Core.Configuration
@@ -40,5 +41,11 @@ public class CreateConfig
4041

4142
[YamlMember(Alias = "include-contributors")]
4243
public bool IncludeContributors { get; set; }
44+
45+
[YamlMember(Alias = "sort-issues-by")]
46+
public SortIssuesBy SortIssuesBy { get; set; } = SortIssuesBy.Id;
47+
48+
[YamlMember(Alias = "sort-issues-direction")]
49+
public SortDirection SortIssuesDirection { get; set; } = SortDirection.Ascending;
4350
}
4451
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace GitReleaseManager.Core.Model
2+
{
3+
public enum SortDirection
4+
{
5+
/// <summary>Ascending.</summary>
6+
Ascending = 0,
7+
8+
/// <summary>Descending.</summary>
9+
Descending = 1,
10+
}
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace GitReleaseManager.Core.Model
2+
{
3+
public enum SortIssuesBy
4+
{
5+
/// <summary>
6+
/// Sort by title of the issue
7+
/// </summary>
8+
Title,
9+
10+
/// <summary>
11+
/// Sort by the Id of the issue
12+
/// </summary>
13+
Id,
14+
}
15+
}

src/GitReleaseManager.Tests/ConfigurationTests.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Text;
44
using GitReleaseManager.Core.Configuration;
5+
using GitReleaseManager.Core.Model;
56
using NUnit.Framework;
67

78
namespace GitReleaseManager.Tests
@@ -127,5 +128,45 @@ public void Should_WriteSample_Multiline_String_Values()
127128
Environment.NewLine);
128129
Assert.That(text, Contains.Substring(expectedText));
129130
}
131+
132+
[Test]
133+
[TestCase(SortIssuesBy.Id, "Id")]
134+
[TestCase(SortIssuesBy.Title, "Title")]
135+
public void Should_Write_SortIssuesBy_Values(SortIssuesBy sortBy, string expected)
136+
{
137+
// Given
138+
var config = new Config();
139+
config.Create.SortIssuesBy = sortBy;
140+
141+
// When
142+
var builder = new StringBuilder();
143+
using (var writer = new StringWriter(builder))
144+
{
145+
ConfigSerializer.Write(config, writer);
146+
}
147+
148+
// Then
149+
Assert.That(builder.ToString(), Contains.Substring($"sort-issues-by: {expected}"));
150+
}
151+
152+
[Test]
153+
[TestCase(SortDirection.Ascending, "Ascending")]
154+
[TestCase(SortDirection.Descending, "Descending")]
155+
public void Should_Write_SortIssuesDirection_Values(SortDirection sortDirection, string expected)
156+
{
157+
// Given
158+
var config = new Config();
159+
config.Create.SortIssuesDirection = sortDirection;
160+
161+
// When
162+
var builder = new StringBuilder();
163+
using (var writer = new StringWriter(builder))
164+
{
165+
ConfigSerializer.Write(config, writer);
166+
}
167+
168+
// Then
169+
Assert.That(builder.ToString(), Contains.Substring($"sort-issues-direction: {expected}"));
170+
}
130171
}
131172
}

0 commit comments

Comments
 (0)