Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

#493 linkable versions in release notes, formatting changes #573

Merged
merged 3 commits into from Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -45,9 +45,11 @@ public String formatReleaseNotes(Collection<ReleaseNotesData> data) {
}

for (ReleaseNotesData d : data) {
sb.append(header(d.getVersion(), d.getDate(), emphasizeVersion));
sb.append(header(d.getVersion(), emphasizeVersion));
String vcsCommitsLink = MessageFormat.format(vcsCommitsLinkTemplate, d.getPreviousVersionVcsTag(), d.getVcsTag());
sb.append(releaseSummary(d.getVersion(), d.getContributions(), contributors, vcsCommitsLink, publicationRepository));
sb.append("\n");
sb.append(releaseSummary(d.getDate(), d.getVersion(), d.getContributions(), contributors, vcsCommitsLink,
publicationRepository));

if (!d.getContributions().getContributions().isEmpty()) {
//no point printing any improvements information if there are no code changes
Expand All @@ -60,20 +62,24 @@ public String formatReleaseNotes(Collection<ReleaseNotesData> data) {
return sb.toString().trim();
}

static String header(String version, Date date, boolean emphasizeVersion) {
return emphasizeVersion ? buildHeader(version, date, "# ", "")
: buildHeader(version, date, "**", "**");
static String header(String version, boolean emphasizeVersion) {
return emphasizeVersion ? buildHeader(version, "# ")
: buildHeader(version, "#### ");
}

private static String buildHeader(String version, String prefix) {
return prefix + version;
}

private static String buildHeader(String version, Date date, String prefix, String postfix) {
return prefix + version + " (" + DateUtil.formatDate(date) + ")" + postfix + " - ";
static String releaseSummary(Date date, String version, ContributionSet contributions, Map<String, Contributor>
contributors, String vcsCommitsLink, String publicationRepository) {
return summaryDatePrefix(date) + authorsSummary(contributions, contributors, vcsCommitsLink)
+ " - published to " + getBintrayBadge(version, publicationRepository) + "\n" +
authorsSummaryAppendix(contributions, contributors);
}

static String releaseSummary(String version, ContributionSet contributions, Map<String, Contributor> contributors,
String vcsCommitsLink, String publicationRepository) {
return authorsSummary(contributions, contributors, vcsCommitsLink) +
" - published to " + getBintrayBadge(version, publicationRepository) + "\n" +
authorsSummaryAppendix(contributions, contributors);
private static String summaryDatePrefix(Date date) {
return " - " + DateUtil.formatDate(date) + " - ";
}

private static String getBintrayBadge(String version, String publicationRepository) {
Expand Down
Expand Up @@ -31,9 +31,11 @@ No release information."""

Release notes:

**2.0.0 (2017-01-04)** - no code changes (no commits) - published to [![Bintray](https://img.shields.io/badge/Bintray-2.0.0-green.svg)](Bintray/2.0.0)
#### 2.0.0
- 2017-01-04 - no code changes (no commits) - published to [![Bintray](https://img.shields.io/badge/Bintray-2.0.0-green.svg)](Bintray/2.0.0)

**1.9.0 (2016-12-30)** - no code changes (no commits) - published to [![Bintray](https://img.shields.io/badge/Bintray-1.9.0-green.svg)](Bintray/1.9.0)"""
#### 1.9.0
- 2016-12-30 - no code changes (no commits) - published to [![Bintray](https://img.shields.io/badge/Bintray-1.9.0-green.svg)](Bintray/1.9.0)"""
}

def "no improvements"() {
Expand All @@ -52,18 +54,19 @@ Release notes:

Release notes:

**2.0.0 (2017-01-04)** - [1 commit](http://commits/v1.9.0...v2.0.0) by Szczepan Faber - published to [![Bintray](https://img.shields.io/badge/Bintray-2.0.0-green.svg)](Bintray/2.0.0)
#### 2.0.0
- 2017-01-04 - [1 commit](http://commits/v1.9.0...v2.0.0) by Szczepan Faber - published to [![Bintray](https://img.shields.io/badge/Bintray-2.0.0-green.svg)](Bintray/2.0.0)
- No pull requests referenced in commit messages."""
}

def "formats header when emphasized version"() {
expect:
DetailedFormatter.header("v0.1.0", new Date(1483500000000), false) == "**v0.1.0 (2017-01-04)** - "
DetailedFormatter.header("v0.1.0", false) == "#### v0.1.0"
}

def "formats header when regular version"() {
expect:
DetailedFormatter.header("v0.1.0", new Date(1483500000000), true) == "# v0.1.0 (2017-01-04) - "
DetailedFormatter.header("v0.1.0", true) == "# v0.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess now emphasized version would be "#", and a regular one "####". What do you think @mockitoguy ?

}

def "formats no improvements"() {
Expand Down Expand Up @@ -154,11 +157,11 @@ Release notes:
c("Tim van der Lippe", 10)]
}

def summary = DetailedFormatter.releaseSummary("1.2.3", c, [:], "link",
def summary = DetailedFormatter.releaseSummary(new Date(1483500000000), "1.2.3", c, [:], "link",
"https://bintray.com/shipkit/")

expect:
summary == """[100 commits](link) by 4 authors - published to [![Bintray](https://img.shields.io/badge/Bintray-1.2.3-green.svg)](https://bintray.com/shipkit/1.2.3)
summary == """ - 2017-01-04 - [100 commits](link) by 4 authors - published to [![Bintray](https://img.shields.io/badge/Bintray-1.2.3-green.svg)](https://bintray.com/shipkit/1.2.3)
- Commits: Szczepan Faber (40), Brice Dutheil (30), Rafael Winterhalter (20), Tim van der Lippe (10)
"""
}
Expand Down