Skip to content

Commit 9358299

Browse files
committed
(GH-90) Relax restriction of one label per issue
Previously GitReleaseManager wasn't able to generate release note for issues with multiple labels. With this change it's become possible, but additional configuration flag needs to be set.
1 parent 50ab605 commit 9358299

13 files changed

+185
-2
lines changed

Source/GitReleaseManager.Tests/ConfigurationTests.cs

+26
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,31 @@ public void Should_Read_Label_Aliases()
3131
Assert.AreEqual("Baz", config.LabelAliases[1].Header);
3232
Assert.AreEqual("Qux", config.LabelAliases[1].Plural);
3333
}
34+
35+
[Test]
36+
public void Many_Labels_For_Issue_Disabled_By_Default()
37+
{
38+
// Given
39+
var text = Resources.Default_Configuration_Yaml;
40+
41+
// When
42+
var config = ConfigSerializer.Read(new StringReader(text));
43+
44+
// Then
45+
Assert.AreEqual(false, config.IssueLabelsMany);
46+
}
47+
48+
[Test]
49+
public void Should_Read_Many_Labels_Issue()
50+
{
51+
// Given
52+
var text = Resources.Many_Labels_For_Issue_Configuration_Yaml;
53+
54+
// When
55+
var config = ConfigSerializer.Read(new StringReader(text));
56+
57+
// Then
58+
Assert.AreEqual(true, config.IssueLabelsMany);
59+
}
3460
}
3561
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
As part of this release we had [1 issue](https://github.com/FakeRepository/issues/issues?milestone=0&state=closed) closed.
2+
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [1 issue](https://github.com/FakeRepository/issues/issues?milestone=0&state=closed) being closed.
2+
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [2 issues](https://github.com/FakeRepository/issues/issues?milestone=0&state=closed) being closed.
2+
3+
4+
__Help Wanteds__
5+
6+
- [__#1__](http://example.com/1) Issue 1
7+
- [__#2__](http://example.com/2) Issue 2
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [2 issues](https://github.com/FakeRepository/issues/issues?milestone=0&state=closed) being closed.
2+
3+
4+
__Bug__
5+
6+
- [__#1__](http://example.com/1) Issue 1
7+
8+
__Help Wanteds__
9+
10+
- [__#1__](http://example.com/1) Issue 1
11+
- [__#2__](http://example.com/2) Issue 2
12+

Source/GitReleaseManager.Tests/ReleaseNotesBuilderTests.cs

+13
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ public void NoCommitsWrongIssueLabel()
110110
Assert.Throws<AggregateException>(() => AcceptTest(0, CreateIssue(1, "Test")));
111111
}
112112

113+
[Test]
114+
public void SomeIssuesWithMultipleLabelsWhenManyLabelsDisabled()
115+
{
116+
Assert.Throws<AggregateException>(() => AcceptTest(5, CreateIssue(1, "Help Wanted", "Bug"), CreateIssue(2, "Help Wanted")));
117+
}
118+
119+
[Test]
120+
public void SomeIssuesWithMultipleLabelsWhenManyLabelsEnabled()
121+
{
122+
var config = new Config {IssueLabelsMany = true};
123+
AcceptTest(5, config, CreateIssue(1, "Help Wanted", "Bug", "Internal Refactoring"), CreateIssue(2, "Help Wanted"));
124+
}
125+
113126
[Test]
114127
public void SomeCommitsWrongIssueLabel()
115128
{

Source/GitReleaseManager.Tests/Resources.Designer.cs

+37-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/GitReleaseManager.Tests/Resources.resx

+34
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,38 @@ issue-labels-alias:
149149
header: Baz
150150
plural: Qux</value>
151151
</data>
152+
<data name="Many_Labels_For_Issue_Configuration_Yaml" xml:space="preserve">
153+
<value>create:
154+
include-footer: false
155+
footer-heading:
156+
footer-content:
157+
footer-includes-milestone: false
158+
milestone-replace-text:
159+
160+
export:
161+
include-created-date-in-title: false
162+
created-date-string-format:
163+
perform-regex-removal: false
164+
regex-text:
165+
multiline-regex: false
166+
167+
issue-labels-include:
168+
- Bug
169+
- Feature
170+
- Improvement
171+
172+
issue-labels-exclude:
173+
- Internal Refactoring
174+
175+
issue-labels-alias:
176+
- name: Bug
177+
header: Foo
178+
plural: Bar
179+
180+
- name: Improvement
181+
header: Baz
182+
plural: Qux
183+
184+
issue-labels-many: true</value>
185+
</data>
152186
</root>

Source/GitReleaseManager/Configuration/Config.cs

+3
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,8 @@ public Config()
6666

6767
[YamlMember(Alias = "issue-labels-alias")]
6868
public IList<LabelAlias> LabelAliases { get; private set; }
69+
70+
[YamlMember(Alias = "issue-labels-many")]
71+
public bool IssueLabelsMany { get; set; }
6972
}
7073
}

Source/GitReleaseManager/ReleaseNotesBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void CheckForValidLabels(Issue issue)
119119
count += this.configuration.IssueLabelsExclude.Count(issueToExclude => issueLabel.Name.ToUpperInvariant() == issueToExclude.ToUpperInvariant());
120120
}
121121

122-
if (count != 1)
122+
if (count != 1 && !this.configuration.IssueLabelsMany)
123123
{
124124
var allIssueLabels = this.configuration.IssueLabelsInclude.Union(this.configuration.IssueLabelsExclude).ToList();
125125
var allIssuesExceptLast = allIssueLabels.Take(allIssueLabels.Count - 1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Enable Many Labels Per Issue
2+
3+
When you are using many labels per issue in your project, you need explicitly tell GitReleaseManager about that, otherwise it won't generate report.
4+
5+
Here is the example of how to configure it:
6+
7+
```
8+
create:
9+
include-footer: false
10+
footer-heading:
11+
footer-content:
12+
footer-includes-milestone: false
13+
milestone-replace-text:
14+
export:
15+
include-created-date-in-title: false
16+
created-date-string-format:
17+
perform-regex-removal: false
18+
regex-text:
19+
multiline-regex: false
20+
issue-labels-include:
21+
- Bug
22+
- Feature
23+
- Improvement
24+
issue-labels-exclude:
25+
- Internal Refactoring
26+
issue-labels-many: true
27+
```
28+
29+
This configuration will generate following report for you:
30+
31+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [2 issues](https://github.com/FakeRepository/issues/issues?milestone=0&state=closed) being closed.
32+
33+
34+
__Bug__
35+
36+
- [__#1__](http://example.com/1) Issue 1
37+
38+
__Improvement__
39+
40+
- [__#1__](http://example.com/1) Issue 1
41+
- [__#2__](http://example.com/2) Issue 2
42+

0 commit comments

Comments
 (0)