Skip to content

(GH-90) Relax restriction of one label per issue #102

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
26 changes: 26 additions & 0 deletions Source/GitReleaseManager.Tests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,31 @@ public void Should_Read_Label_Aliases()
Assert.AreEqual("Baz", config.LabelAliases[1].Header);
Assert.AreEqual("Qux", config.LabelAliases[1].Plural);
}

[Test]
public void Many_Labels_For_Issue_Disabled_By_Default()
{
// Given
var text = Resources.Default_Configuration_Yaml;

// When
var config = ConfigSerializer.Read(new StringReader(text));

// Then
Assert.AreEqual(false, config.IssueLabelsMany);
}

[Test]
public void Should_Read_Many_Labels_Issue()
{
// Given
var text = Resources.Many_Labels_For_Issue_Configuration_Yaml;

// When
var config = ConfigSerializer.Read(new StringReader(text));

// Then
Assert.AreEqual(true, config.IssueLabelsMany);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

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


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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.


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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.


__Help Wanteds__

- [__#1__](http://example.com/1) Issue 1
- [__#2__](http://example.com/2) Issue 2


Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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.


__Bug__

- [__#1__](http://example.com/1) Issue 1

__Help Wanteds__

- [__#1__](http://example.com/1) Issue 1
- [__#2__](http://example.com/2) Issue 2

13 changes: 13 additions & 0 deletions Source/GitReleaseManager.Tests/ReleaseNotesBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ public void NoCommitsWrongIssueLabel()
Assert.Throws<AggregateException>(() => AcceptTest(0, CreateIssue(1, "Test")));
}

[Test]
public void SomeIssuesWithMultipleLabelsWhenManyLabelsDisabled()
{
Assert.Throws<AggregateException>(() => AcceptTest(5, CreateIssue(1, "Help Wanted", "Bug"), CreateIssue(2, "Help Wanted")));
}

[Test]
public void SomeIssuesWithMultipleLabelsWhenManyLabelsEnabled()
{
var config = new Config {IssueLabelsMany = true};
AcceptTest(5, config, CreateIssue(1, "Help Wanted", "Bug", "Internal Refactoring"), CreateIssue(2, "Help Wanted"));
}

[Test]
public void SomeCommitsWrongIssueLabel()
{
Expand Down
38 changes: 37 additions & 1 deletion Source/GitReleaseManager.Tests/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Source/GitReleaseManager.Tests/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,38 @@ issue-labels-alias:
header: Baz
plural: Qux</value>
</data>
<data name="Many_Labels_For_Issue_Configuration_Yaml" xml:space="preserve">
<value>create:
include-footer: false
footer-heading:
footer-content:
footer-includes-milestone: false
milestone-replace-text:

export:
include-created-date-in-title: false
created-date-string-format:
perform-regex-removal: false
regex-text:
multiline-regex: false

issue-labels-include:
- Bug
- Feature
- Improvement

issue-labels-exclude:
- Internal Refactoring

issue-labels-alias:
- name: Bug
header: Foo
plural: Bar

- name: Improvement
header: Baz
plural: Qux

issue-labels-many: true</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Source/GitReleaseManager/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,8 @@ public Config()

[YamlMember(Alias = "issue-labels-alias")]
public IList<LabelAlias> LabelAliases { get; private set; }

[YamlMember(Alias = "issue-labels-many")]
public bool IssueLabelsMany { get; set; }
}
}
2 changes: 1 addition & 1 deletion Source/GitReleaseManager/ReleaseNotesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void CheckForValidLabels(Issue issue)
count += this.configuration.IssueLabelsExclude.Count(issueToExclude => issueLabel.Name.ToUpperInvariant() == issueToExclude.ToUpperInvariant());
}

if (count != 1)
if (count != 1 && !this.configuration.IssueLabelsMany)
{
var allIssueLabels = this.configuration.IssueLabelsInclude.Union(this.configuration.IssueLabelsExclude).ToList();
var allIssuesExceptLast = allIssueLabels.Take(allIssueLabels.Count - 1);
Expand Down
42 changes: 42 additions & 0 deletions docs/configuration/enable-many-labels-per-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Enable Many Labels Per Issue

When you are using many labels per issue in your project, you need explicitly tell GitReleaseManager about that, otherwise it won't generate report.

Here is the example of how to configure it:

```
create:
include-footer: false
footer-heading:
footer-content:
footer-includes-milestone: false
milestone-replace-text:
export:
include-created-date-in-title: false
created-date-string-format:
perform-regex-removal: false
regex-text:
multiline-regex: false
issue-labels-include:
- Bug
- Feature
- Improvement
issue-labels-exclude:
- Internal Refactoring
issue-labels-many: true
```

This configuration will generate following report for you:

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.


__Bug__

- [__#1__](http://example.com/1) Issue 1

__Improvement__

- [__#1__](http://example.com/1) Issue 1
- [__#2__](http://example.com/2) Issue 2