Skip to content

Commit

Permalink
Fix: release note highlighted when a pull request has the label
Browse files Browse the repository at this point in the history
  • Loading branch information
EbenZhang committed Nov 13, 2020
1 parent 5a99890 commit aca8965
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Utility can have command line parameters passed to it or have the parameters sup
- `-ReleaseNoteOrderWhen` (`-rnow`) : Default ("merged"). Set to "created" to order release notes based on pull request creation time rather than merge time.
- `-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
- `-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.
- `-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.'
- `-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.'
- `-PublishToConfluence` (`-ptc`) : Default ("false"). Set to "true" for all other Confluence related parameters to become active.
- `-ConfluenceReleaseParentPageId` (`-cpp`) : Confluence parent page identifer. Pulished page will be its child page.
- `-ConfluenceSpaceKey` (`-csk`) : Required parameter if `PublishToConfluence` is true.
Expand Down
31 changes: 31 additions & 0 deletions src/PullRequestReleaseNotes.Tests/Models/PullRequestDtoTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using PullRequestReleaseNotes.Models;
using Shouldly;

namespace PullRequestReleaseNotes.Tests.Models
{
[TestFixture]
public class PullRequestDtoTests
{
[TestCase("a,b,c,h", "h", false)]
[TestCase("a,b,c", "h", true)]
[TestCase("a,b,c,h", "h,a", false)]
public void Highlight(string labels, string highlightWhenMissing, bool highlight)
{
var dto = new PullRequestDto
{
Labels = Split(labels)
};

dto.Highlighted(Split(highlightWhenMissing)).ShouldBe(highlight);
}

private static List<string> Split(string str)
{
return str.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();
}
}
}
2 changes: 1 addition & 1 deletion src/PullRequestReleaseNotes/Models/ProgramArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ProgramArgs

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

[ArgShortcut("-ghb")]
Expand Down
2 changes: 1 addition & 1 deletion src/PullRequestReleaseNotes/Models/PullRequestDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public bool Highlighted(List<string> highlightLabels)
{
if (highlightLabels == null || highlightLabels.All(string.IsNullOrWhiteSpace))
return false;
return Labels.Intersect(highlightLabels, StringComparer.InvariantCultureIgnoreCase).Count() != 0;
return Labels.Intersect(highlightLabels, StringComparer.InvariantCultureIgnoreCase).Count() != highlightLabels.Count;
}
}
}

0 comments on commit aca8965

Please sign in to comment.