Skip to content

Commit bdad878

Browse files
authored
Merge pull request #44 from EbenZhang/master
Fix: release note highlighted when a pull request has the label
2 parents 5a99890 + aca8965 commit bdad878

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

docs/HELP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Utility can have command line parameters passed to it or have the parameters sup
4141
- `-ReleaseNoteOrderWhen` (`-rnow`) : Default ("merged"). Set to "created" to order release notes based on pull request creation time rather than merge time.
4242
- `-ReleaseNoteFormat` (`-rnf`) : Default ("{0} {1}"). Available fields are {0} pull request title, {1} pull request url, {2} pull request number, {3} pull request created date/time, {4} pull request merged date/time, {5} pull request author username, {6} pull request author URL, {7} pull request documentation URL
4343
- `-ReleaseNoteDateFormat` (`-rndf`) : Default ("MMM dd, yyyy HH:mm"). You can use any [.NET standard](https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx) or [custom date and time format](https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx) strings.
44-
- `-ReleaseNoteHighlightLabels` (`-rnhl`) : Default is (""). Comma-separated list of labels which a pull request without will be marked up as code to highlight the item in release notes.'
44+
- `-ReleaseNoteHighlightLabels` (`-rnhl`) : Default is (""). Comma-separated list of labels which a pull request WITHOUT will be marked up as code to highlight the item in release notes.'
4545
- `-PublishToConfluence` (`-ptc`) : Default ("false"). Set to "true" for all other Confluence related parameters to become active.
4646
- `-ConfluenceReleaseParentPageId` (`-cpp`) : Confluence parent page identifer. Pulished page will be its child page.
4747
- `-ConfluenceSpaceKey` (`-csk`) : Required parameter if `PublishToConfluence` is true.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using NUnit.Framework;
5+
using PullRequestReleaseNotes.Models;
6+
using Shouldly;
7+
8+
namespace PullRequestReleaseNotes.Tests.Models
9+
{
10+
[TestFixture]
11+
public class PullRequestDtoTests
12+
{
13+
[TestCase("a,b,c,h", "h", false)]
14+
[TestCase("a,b,c", "h", true)]
15+
[TestCase("a,b,c,h", "h,a", false)]
16+
public void Highlight(string labels, string highlightWhenMissing, bool highlight)
17+
{
18+
var dto = new PullRequestDto
19+
{
20+
Labels = Split(labels)
21+
};
22+
23+
dto.Highlighted(Split(highlightWhenMissing)).ShouldBe(highlight);
24+
}
25+
26+
private static List<string> Split(string str)
27+
{
28+
return str.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();
29+
}
30+
}
31+
}

src/PullRequestReleaseNotes/Models/ProgramArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class ProgramArgs
4949

5050
[ArgShortcut("-rnhl")]
5151
[YamlMember(Alias = "release-note-highlight-labels")]
52-
[ArgExample("Label1,Label2", "List of labels which a pull request without will be marked up as code to highlight the item in release notes.")]
52+
[ArgExample("Label1,Label2", "List of labels which a pull request WITHOUT will be marked up as code to highlight the item in release notes.")]
5353
public List<string> ReleaseNoteHighlightLabels { get; set; }
5454

5555
[ArgShortcut("-ghb")]

src/PullRequestReleaseNotes/Models/PullRequestDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public bool Highlighted(List<string> highlightLabels)
2626
{
2727
if (highlightLabels == null || highlightLabels.All(string.IsNullOrWhiteSpace))
2828
return false;
29-
return Labels.Intersect(highlightLabels, StringComparer.InvariantCultureIgnoreCase).Count() != 0;
29+
return Labels.Intersect(highlightLabels, StringComparer.InvariantCultureIgnoreCase).Count() != highlightLabels.Count;
3030
}
3131
}
3232
}

0 commit comments

Comments
 (0)