danger-changelog 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fb5aff25f4ccf5fc339a15cf5a542348e92929f87d0b41945f190c08caee0db
4
- data.tar.gz: d4f672480a57b9c21fcd75f68ec0153917ce308d263e8cc4fe41df14be644c5f
3
+ metadata.gz: 23ffe294b89bbc0ab12ea04d4ec4047537296e946185c8c429d2a0342b99f5f3
4
+ data.tar.gz: 12d61d6e00b7bafda8f4007b12219f33a11b0b3e12b5442404fb2ff419b263e8
5
5
  SHA512:
6
- metadata.gz: 3623da33104a8ef38cc1a05916afc9ed22c1294e93e3e39c6520d29b69ded74357d31045398b25c596a8083abd2b5194a0653248b4f151512b94fec08468f18c
7
- data.tar.gz: b31a67bcd03090eb70bdbbd5b64b8ba903a9df163b4a60dae4f18757efab974bcdf0c252ea5ad88d5ef3949e8c9c885769456f1efab4271a20018b883b7ff570
6
+ metadata.gz: 844b03efdd6dbda1f354d0473471ff768d0fe39774521f5e5d092b8b2cc1febcbae5bda93fef8f9da6488e3c4b13c1fb385303b10e37debd7d546a953687875d
7
+ data.tar.gz: 94016cf396222b1b0c06eb78b3c940eddc7bf3b4f7fd0114ee5a7779317067f8f33ca4e58348ff629a6c99f470977878676c9c803b47c56ef83d267b3196fbd2
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-12-16 11:08:47 -0500 using RuboCop version 0.61.1.
3
+ # on 2018-12-20 12:04:45 -0500 using RuboCop version 0.61.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.4.1 (2018/12/20)
4
+
5
+ * [#37](https://github.com/dblock/danger-changelog/issues/37): Allow for parenthesis and brackets around versions and dates - [@dblock](https://github.com/dblock).
6
+ * [#38](https://github.com/dblock/danger-changelog/pull/38): Check for imbalanced parenthesis and brackets - [@dblock](https://github.com/dblock).
7
+
3
8
  ### 0.4.0 (2018/12/16)
4
9
 
5
10
  * [#35](https://github.com/dblock/danger-changelog/pull/35): Check that dates in headers are ISO8601 - [@dblock](https://github.com/dblock).
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # danger-changelog
2
2
 
3
3
  A plugin for [danger.systems](http://danger.systems) that obsessive-compulsively lints your project’s `CHANGELOG.md`.
4
- It can make sure, for example, that changes are attributed properly, have a valid version number, a date in the ISO8601 format, and that they’re always terminated with a period.
4
+ It can make sure, for example, that changes are attributed properly, have a valid version number, a date in the ISO8601 format, balanced parenthesis and brackets, and that they’re always terminated with a period.
5
5
 
6
6
  [![Gem Version](https://badge.fury.io/rb/danger-changelog.svg)](https://badge.fury.io/rb/danger-changelog)
7
7
  [![Build Status](https://travis-ci.org/dblock/danger-changelog.svg?branch=master)](https://travis-ci.org/dblock/danger-changelog)
@@ -5,6 +5,7 @@ module Danger
5
5
  # A CHANGELOG.md line represents the change entry.
6
6
  class ChangelogEntryLine < ChangelogLine
7
7
  def valid?
8
+ return false unless balanced?(line)
8
9
  return true if line =~ %r{^\*\s[\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
9
10
  return true if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
10
11
 
@@ -2,17 +2,25 @@ module Danger
2
2
  module Changelog
3
3
  # A CHANGELOG.md line represents the version header.
4
4
  class ChangelogHeaderLine < ChangelogLine
5
+ OPEN_PARENS = /[\(\[\{]?/.freeze
6
+ CLOSE_PARENS = /[\)\]\}]?/.freeze
7
+
8
+ HASHES = /\#{1,4}/.freeze
9
+ SEMVER = /(?<semver>(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)/.freeze
10
+ ISO8601_DATE = %r{(?<date>([0-9]{4})[-/]?(1[0-2]|0?[1-9])[-/]+(3[01]|0?[1-9]|[12][0-9]))}.freeze
11
+
5
12
  def valid?
6
- return true if line.strip =~ /^\#{1,4}\s[\w\s]*$/ # title
7
- return true if line.strip =~ /^\#{1,4}\s(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ # no date at all
8
- return true if line.strip =~ /^\#{1,4}\s(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?\s\(\w*\)$/ # next date
9
- return true if line.strip =~ %r{^\#{1,4}\s(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?\s\(([0-9]{4})[-/]?(1[0-2]|0?[1-9])[-/]+(3[01]|0?[1-9]|[12][0-9])\)$} # iso 8601 date
13
+ stripped_line = line.strip
10
14
 
11
- false
15
+ m = stripped_line.match(/^#{HASHES}\s[\w\s\:]*$/) # title
16
+ m ||= stripped_line.match(/^#{HASHES}\s#{OPEN_PARENS}#{SEMVER}#{CLOSE_PARENS}$/) # semver only
17
+ m ||= stripped_line.match(/^#{HASHES}\s#{OPEN_PARENS}#{SEMVER}#{CLOSE_PARENS}[\s\-]+#{OPEN_PARENS}(#{ISO8601_DATE}|\w*)#{CLOSE_PARENS}$/) # semver and iso 8601 date or next version description
18
+
19
+ !m.nil? && balanced?(stripped_line)
12
20
  end
13
21
 
14
22
  def self.validates_as_changelog_line?(line)
15
- return true if line =~ /^\#{1,4}\s.+/
23
+ return true if line =~ /^#{HASHES}\s.+/
16
24
 
17
25
  false
18
26
  end
@@ -2,6 +2,10 @@ module Danger
2
2
  module Changelog
3
3
  # An abstract CHANGELOG.md line.
4
4
  class ChangelogLine
5
+ NON_DELIMITERS = /[^(){}\[\]]*/.freeze
6
+ PAIRED = /\(#{NON_DELIMITERS}\)|\{#{NON_DELIMITERS}\}|\[#{NON_DELIMITERS}\]/.freeze
7
+ DELIMITER = /[(){}\[\]]/.freeze
8
+
5
9
  attr_accessor :line
6
10
 
7
11
  def initialize(line)
@@ -22,6 +26,13 @@ module Danger
22
26
  def self.validates_as_changelog_line?(_line)
23
27
  abort "You need to include a function for #{self} for validates_as_changelog_line?"
24
28
  end
29
+
30
+ # https://stackoverflow.com/questions/25979364/ruby-regex-for-matching-brackets
31
+ def balanced?(line_with_parens)
32
+ line_with_parens = line_with_parens.dup
33
+ line_with_parens.gsub!(PAIRED, ''.freeze) while line_with_parens =~ PAIRED
34
+ line_with_parens !~ DELIMITER
35
+ end
25
36
  end
26
37
  end
27
38
  end
@@ -1,3 +1,3 @@
1
1
  module Changelog
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
@@ -41,7 +41,7 @@ describe Danger::Changelog::ChangelogFile do
41
41
  end
42
42
  end
43
43
  context 'with bad lines' do
44
- let(:filename) { File.expand_path('fixtures/changelogs/with_bad_lines.md', __dir__) }
44
+ let(:filename) { File.expand_path('fixtures/changelogs/lines.md', __dir__) }
45
45
  it 'is invalid' do
46
46
  expect(subject.bad_lines?).to be true
47
47
  end
@@ -51,7 +51,9 @@ describe Danger::Changelog::ChangelogFile do
51
51
  "* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n",
52
52
  "* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n",
53
53
  "# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).\n",
54
- "* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n"
54
+ "* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n",
55
+ "* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ( - [@dblock](https://github.com/dblock).\n",
56
+ "* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ] - [@dblock](https://github.com/dblock).\n"
55
57
  ]
56
58
  end
57
59
  it 'has your contribution here' do
@@ -59,7 +61,7 @@ describe Danger::Changelog::ChangelogFile do
59
61
  end
60
62
  end
61
63
  context 'with bad dates' do
62
- let(:filename) { File.expand_path('fixtures/changelogs/with_bad_dates.md', __dir__) }
64
+ let(:filename) { File.expand_path('fixtures/changelogs/dates.md', __dir__) }
63
65
  it 'is invalid' do
64
66
  expect(subject.bad_lines?).to be true
65
67
  end
@@ -73,7 +75,7 @@ describe Danger::Changelog::ChangelogFile do
73
75
  end
74
76
  end
75
77
  context 'with bad semver' do
76
- let(:filename) { File.expand_path('fixtures/changelogs/with_bad_semver.md', __dir__) }
78
+ let(:filename) { File.expand_path('fixtures/changelogs/semver.md', __dir__) }
77
79
  it 'is invalid' do
78
80
  expect(subject.bad_lines?).to be true
79
81
  end
@@ -85,4 +87,21 @@ describe Danger::Changelog::ChangelogFile do
85
87
  ]
86
88
  end
87
89
  end
90
+ context 'with imbalanced parenthesis' do
91
+ let(:filename) { File.expand_path('fixtures/changelogs/imbalanced.md', __dir__) }
92
+ it 'is invalid' do
93
+ expect(subject.bad_lines?).to be true
94
+ end
95
+ it 'reports all bad lines' do
96
+ expect(subject.bad_lines).to eq [
97
+ "### 0.0.0)\n",
98
+ "### (0.0.1\n",
99
+ "### 1.2.3 (2018/1/1\n",
100
+ "### 0.1.0 2018/1/1)\n",
101
+ "### 0 ((2018/1/1)\n",
102
+ "### 0. [2018/1/1)\n",
103
+ "### 0.1. (2018/1/1)]\n"
104
+ ]
105
+ end
106
+ end
88
107
  end
@@ -188,7 +188,7 @@ describe Danger::Changelog do
188
188
  end
189
189
 
190
190
  context 'with bad lines' do
191
- let(:filename) { File.expand_path('fixtures/changelogs/with_bad_lines.md', __dir__) }
191
+ let(:filename) { File.expand_path('fixtures/changelogs/lines.md', __dir__) }
192
192
  it 'complains' do
193
193
  expect(subject).to be false
194
194
  expect(status_report[:errors]).to eq ["One of the lines below found in #{filename} doesn't match the expected format. Please make it look like the other lines, pay attention to version numbers, periods, spaces and date formats."]
@@ -198,7 +198,9 @@ describe Danger::Changelog do
198
198
  "```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n```\n",
199
199
  "```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n```\n",
200
200
  "```markdown\n# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).\n```\n",
201
- "```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n```\n"
201
+ "```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n```\n",
202
+ "```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ( - [@dblock](https://github.com/dblock).\n```\n",
203
+ "```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ] - [@dblock](https://github.com/dblock).\n```\n"
202
204
  ]
203
205
  end
204
206
  end
@@ -0,0 +1,13 @@
1
+ ## Changelog
2
+
3
+ ### 1.2.3 (Next)
4
+ ### 1.2.3 - Next
5
+ ### 1.2.3 (2018/1/2)
6
+ ### 1.2.3 (2018-1-2)
7
+ ### 1.2.3 (2018-01-02)
8
+ ### 1.2.3 (2018/01/02)
9
+ ### 1.2.3 (1/2/2018)
10
+ ### 1.2.3 (2018/13/1)
11
+ ### 1.2.3 (2018/13)
12
+ ### 1.2.3 (2018/1/1/3)
13
+ ### 1.2.3 - 2018/01/02
@@ -0,0 +1,7 @@
1
+ ### 0.0.0)
2
+ ### (0.0.1
3
+ ### 1.2.3 (2018/1/1
4
+ ### 0.1.0 2018/1/1)
5
+ ### 0 ((2018/1/1)
6
+ ### 0. [2018/1/1)
7
+ ### 0.1. (2018/1/1)]
@@ -5,4 +5,6 @@ Missing star - [@dblock](https://github.com/dblock).
5
5
  * [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)
6
6
  # [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).
7
7
  * [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).
8
+ * [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ( - [@dblock](https://github.com/dblock).
9
+ * [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ] - [@dblock](https://github.com/dblock).
8
10
  * Your contribution here.
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### Changed:
4
+ ### Fixed:
5
+
3
6
  ### 0.0.0
4
7
  ### 0.0.1
5
8
  ### 1.2.3 (2018/1/1)
@@ -10,3 +13,7 @@
10
13
  ### 0.0.4
11
14
  ### 10.2.3-DEV-SNAPSHOT
12
15
  ### 99999999999999999999999.999999999999999999.99999999999999999
16
+
17
+ ### 0.1.1 [2018/1/1]
18
+ ### [0.1.1] [2018/1/1]
19
+ ## [0.2.2] - 2017-06-20
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dblock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-16 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -193,11 +193,12 @@ files:
193
193
  - spec/changelog_spec.rb
194
194
  - spec/config_spec.rb
195
195
  - spec/fixtures/changelogs/customized.md
196
+ - spec/fixtures/changelogs/dates.md
197
+ - spec/fixtures/changelogs/imbalanced.md
198
+ - spec/fixtures/changelogs/lines.md
196
199
  - spec/fixtures/changelogs/minimal.md
197
200
  - spec/fixtures/changelogs/missing_your_contribution_here.md
198
- - spec/fixtures/changelogs/with_bad_dates.md
199
- - spec/fixtures/changelogs/with_bad_lines.md
200
- - spec/fixtures/changelogs/with_bad_semver.md
201
+ - spec/fixtures/changelogs/semver.md
201
202
  - spec/spec_helper.rb
202
203
  homepage: https://github.com/dblock/danger-changelog
203
204
  licenses:
@@ -232,9 +233,10 @@ test_files:
232
233
  - spec/changelog_spec.rb
233
234
  - spec/config_spec.rb
234
235
  - spec/fixtures/changelogs/customized.md
236
+ - spec/fixtures/changelogs/dates.md
237
+ - spec/fixtures/changelogs/imbalanced.md
238
+ - spec/fixtures/changelogs/lines.md
235
239
  - spec/fixtures/changelogs/minimal.md
236
240
  - spec/fixtures/changelogs/missing_your_contribution_here.md
237
- - spec/fixtures/changelogs/with_bad_dates.md
238
- - spec/fixtures/changelogs/with_bad_lines.md
239
- - spec/fixtures/changelogs/with_bad_semver.md
241
+ - spec/fixtures/changelogs/semver.md
240
242
  - spec/spec_helper.rb
@@ -1,25 +0,0 @@
1
- ## Changelog
2
-
3
- ### 1.2.3 (Next)
4
-
5
- * Your contribution here.
6
-
7
- ### 1.2.3 (2018/1/2)
8
-
9
- * [#1](https://github.com/dblock/danger-changelog/pull/1): Change - [@dblock](https://github.com/dblock).
10
-
11
- ### 1.2.3 (1/2/2018)
12
-
13
- * [#1](https://github.com/dblock/danger-changelog/pull/1): Change - [@dblock](https://github.com/dblock).
14
-
15
- ### 1.2.3 (2018/13/1)
16
-
17
- * [#1](https://github.com/dblock/danger-changelog/pull/1): Change - [@dblock](https://github.com/dblock).
18
-
19
- ### 1.2.3 (2018/13)
20
-
21
- * [#1](https://github.com/dblock/danger-changelog/pull/1): Change - [@dblock](https://github.com/dblock).
22
-
23
- ### 1.2.3 (2018/1/1/3)
24
-
25
- * [#1](https://github.com/dblock/danger-changelog/pull/1): Change - [@dblock](https://github.com/dblock).