From ba6fa6bf63ae83ee24407cad4c5dbbfa3f5d79ce Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 4 Dec 2019 00:44:50 -0800 Subject: [PATCH] Scale back our ambitions a little bit. --- README.md | 25 ++++++------------- .../spotless/changelog/ChangelogModel.java | 5 +--- .../changelog/gradle/ChangelogExtension.java | 24 +++--------------- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index d5a687e..13c26d7 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ output = [ [![JitCI](https://jitci.com/gh/diffplug/spotless-changelog/svg)](https://jitci.com/gh/diffplug/spotless-changelog) -Spotless Changelog checks that your changelog complies with the format of [keepachangelog](https://keepachangelog.com/), and uses the information from **only the changelog file** to compute the version of the next release. If you want, you can use the computed version to update the changelog file, then commit, tag, and push whenever a release is published. +Spotless Changelog checks that your changelog complies with the format of [keepachangelog](https://keepachangelog.com/), and uses the information from **only the changelog file** to compute the version of the next release. If you want, you can use the computed version to update the changelog file, then automatically commit, tag, and push when a release is published. There are [many plugins](https://plugins.gradle.org/search?term=version) that compute your next version using a variety of configurable rules based on git tags, commit message standards, class file comparison, and other methods. They tend to require a lot of documentation. If your changelog doesn't already have information about breaking changes and new features, then you should fix that first, whether you end up adopting this plugin or not! But once your changelog has that information, why not make things simple and use it as the source-of-truth? If you want, there are also plugins which can generate your changelog automatically from your [git commits](https://plugins.gradle.org/search?term=git+changelog) or [github issues](https://plugins.gradle.org/search?term=github+changelog) (although we tend to think that's overkill). -Currently Spotless Changelog only has a gradle plugin, but the logic lives in a separate lib, and we welcome contributions for other build systems, just [as happened with the Spotless code formatter](https://github.com/diffplug/spotless/issues/102). +Currently Spotless Changelog only has a gradle plugin, but the logic lives in a separate library, and we welcome contributions for other build systems, just [as happened with the Spotless code formatter](https://github.com/diffplug/spotless/issues/102). ## Keep your changelog clean @@ -54,12 +54,13 @@ plugins { spotlessChangelog { // only necessary if you need to change the defaults below changelogFile 'CHANGELOG.md' - types ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'] enforceCheck true } ``` -The `changelogCheck` task will now run every time `gradlew check` runs, and it will verify that the changelog conforms to the changelog format, and that every change type is one of the allowed types. +The `changelogCheck` task will now run every time `gradlew check` runs, and it will verify that the changelog versions and dates conform to the format. + +It *does not* enforce the entire keepachangelog format, only the `## [x.y.z] yyyy-mm-dd` lines. We're happy to take a PR to support a stricter format, but it will be optional. ### Legacy changelogs @@ -73,17 +74,7 @@ When computing the next version, Spotless Changelog always starts with the most ```gradle spotlessChangelog { // defaults - typesBumpMinor ['Added'] - typesBumpMajor ['Changed', 'Removed'] - ifFoundBumpMajor ['**BREAKING**'] -} -``` - -The defaults above are what is required for [semver](https://semver.org/). If you want more control over when you bump the major version, you could do this: - -```gradle -spotlessChangelog { // but semver is good! use it! don't mistake your version for a brand! - typesBumpMajor [] + ifFoundBumpMinor ['### Added'] ifFoundBumpMajor ['**BREAKING**'] } ``` @@ -123,11 +114,9 @@ If `release` is the task that publishes your library, then `tasks.release.finali spotlessChangelog { // all defaults // keep changelog formatted changelogFile 'CHANGELOG.md' - types ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'] enforceCheck true // calculate next version - typesBumpMinor ['Added'] - typesBumpMajor ['Changed', 'Removed'] + ifFoundBumpMinor ['### Added'] ifFoundBumpMajor ['**BREAKING**'] forceNextVersion null // tag and push diff --git a/spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/ChangelogModel.java b/spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/ChangelogModel.java index a7fc06f..b9c3523 100644 --- a/spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/ChangelogModel.java +++ b/spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/ChangelogModel.java @@ -30,14 +30,11 @@ public class ChangelogModel { public static final String DONT_PARSE_BELOW_HERE = ""; public static class NextVersionCfg implements Serializable { - public List types = Arrays.asList("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"); - public List typesBumpMinor = Arrays.asList("Added"); - public List typesBumpMajor = Arrays.asList("Changed", "Removed"); + public List ifFoundBumpMinor = Arrays.asList("###", "Removed"); public List ifFoundBumpMajor = Arrays.asList("**BREAKING**"); public @NullOr String forceNextVersion = null; } - // tag and push public static class PushCfg { public String tagPrefix = "release/"; public String commitMessage = "Published release/" + COMMIT_MESSAGE_VERSION; diff --git a/spotless-changelog-plugin-gradle/src/main/java/com/diffplug/spotless/changelog/gradle/ChangelogExtension.java b/spotless-changelog-plugin-gradle/src/main/java/com/diffplug/spotless/changelog/gradle/ChangelogExtension.java index e827805..9ca6c12 100644 --- a/spotless-changelog-plugin-gradle/src/main/java/com/diffplug/spotless/changelog/gradle/ChangelogExtension.java +++ b/spotless-changelog-plugin-gradle/src/main/java/com/diffplug/spotless/changelog/gradle/ChangelogExtension.java @@ -47,33 +47,17 @@ public void changelogFile(Object file) { changelogFile = project.file(file); } - public void types(String... types) { - types(Arrays.asList(types)); - } - - public void types(List types) { - nextVersionCfg.types = types; - } - public void enforceCheck(boolean enforceCheck) { this.enforceCheck = enforceCheck; } // calculate next version - public void typesBumpMinor(String... types) { - typesBumpMinor(Arrays.asList(types)); - } - - public void typesBumpMinor(List types) { - nextVersionCfg.typesBumpMinor = types; - } - - public void typesBumpMajor(String... types) { - typesBumpMajor(Arrays.asList(types)); + public void ifFoundBumpMinor(String... types) { + ifFoundBumpMajor(Arrays.asList(types)); } - public void typesBumpMajor(List types) { - nextVersionCfg.typesBumpMajor = types; + public void ifFoundBumpMinor(List types) { + nextVersionCfg.ifFoundBumpMinor = types; } public void ifFoundBumpMajor(String... types) {