From d8259e10adf0652f024e2c4903e2d46ec616ca38 Mon Sep 17 00:00:00 2001 From: dotmpe Date: Thu, 22 Sep 2016 17:06:25 +0200 Subject: [PATCH] Add regex to allow single line versions. (#15) * Add regex to allow single line versions. Regex matching lines starting with digit, followed by semver allowed characters only. Enables use of rST definitions lists for main changelog format. * Loosened rst-dl regex. Added tests. * Re-added ``You contribution here!`` bullet point --- CHANGELOG.md | 1 + lib/chandler/changelog.rb | 3 ++- test/chandler/changelog_test.rb | 11 +++++++++++ test/fixtures/changelog/rst-definition.md | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/changelog/rst-definition.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d42570..0495a49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ chandler is in a pre-1.0 state. This means that its APIs and behavior are subjec ## [Unreleased][] * Your contribution here! +* Support for reStructuredText `definition-list` style CHANGELOG layouts. ## [0.3.1][] (2016-05-13) diff --git a/lib/chandler/changelog.rb b/lib/chandler/changelog.rb index 6a4edd8..7ecab30 100644 --- a/lib/chandler/changelog.rb +++ b/lib/chandler/changelog.rb @@ -17,7 +17,8 @@ class Changelog /^==[[:space:]]+.*\n/, /^===[[:space:]]+.*\n/, /^\S.*\n=+\n/, # Markdown "Setext" style - /^\S.*\n-+\n/ + /^\S.*\n-+\n/, + /^[vr]?[0-9]+\S+[[:space:]]*\n/ # Lines with version string ].freeze attr_reader :path diff --git a/test/chandler/changelog_test.rb b/test/chandler/changelog_test.rb index ef6a914..6fdaf84 100644 --- a/test/chandler/changelog_test.rb +++ b/test/chandler/changelog_test.rb @@ -144,6 +144,17 @@ def test_fetch_realm_cocoa assert_match("RLMArray has been split into", changelog.fetch("v0.87.0")) end + def test_fetch_rst_definitions_semver + changelog = new_changelog("rst-definition.md") + + assert_match("Added ACME project", changelog.fetch("0.0.1")) + assert_match("Pre-release", changelog.fetch("0.0.2-rc1")) + assert_match("Dev pre-release", changelog.fetch("0.0.2-dev-xyz")) + assert_match("Release", changelog.fetch("0.0.2")) + assert_match("Release 0.1", changelog.fetch("0.1.0")) + assert_match("Update", changelog.fetch("v0.1.1")) + end + def test_fetch_rubocop_versions changelog = new_changelog("rubocop.md") diff --git a/test/fixtures/changelog/rst-definition.md b/test/fixtures/changelog/rst-definition.md new file mode 100644 index 0000000..79f8185 --- /dev/null +++ b/test/fixtures/changelog/rst-definition.md @@ -0,0 +1,18 @@ +0.0.1 + - Added ACME project. + +0.0.2-rc1 + - Pre-release. + +0.0.2-dev-xyz + - Dev pre-release. + +0.0.2 + - Release. + +0.1.0 + - Release 0.1 + +v0.1.1 + - Update. +