danger-changelog 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/danger.yml +23 -0
  3. data/.github/workflows/lint.yml +16 -0
  4. data/.github/workflows/test.yml +20 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +10 -0
  7. data/.rubocop_todo.yml +1 -39
  8. data/CHANGELOG.md +11 -0
  9. data/CONTRIBUTING.md +1 -1
  10. data/Dangerfile +1 -0
  11. data/Gemfile +14 -0
  12. data/LICENSE.txt +1 -1
  13. data/README.md +20 -3
  14. data/RELEASING.md +1 -1
  15. data/danger-changelog.gemspec +0 -11
  16. data/lib/changelog/changelog_file.rb +5 -3
  17. data/lib/changelog/changelog_line/changelog_entry_line.rb +31 -1
  18. data/lib/changelog/changelog_line/changelog_header_line.rb +2 -2
  19. data/lib/changelog/changelog_line/changelog_line.rb +2 -0
  20. data/lib/changelog/changelog_line/changelog_line_parser.rb +2 -2
  21. data/lib/changelog/config.rb +4 -2
  22. data/lib/changelog/gem_version.rb +1 -1
  23. data/lib/changelog/parsers/base.rb +2 -2
  24. data/lib/changelog/parsers/intridea_format.rb +2 -1
  25. data/lib/changelog/parsers/keep_a_changelog.rb +2 -2
  26. data/lib/changelog/parsers/validation_result.rb +31 -0
  27. data/lib/changelog/parsers.rb +1 -0
  28. data/lib/changelog/plugin.rb +10 -9
  29. data/spec/changelog_spec.rb +88 -254
  30. data/spec/config_spec.rb +11 -3
  31. data/spec/{changelog_entry_line_spec.rb → intridea/changelog_entry_line_spec.rb} +1 -1
  32. data/spec/intridea/changelog_file_spec.rb +120 -0
  33. data/spec/{changelog_header_line_spec.rb → intridea/changelog_header_line_spec.rb} +1 -1
  34. data/spec/{changelog_line_parser_spec.rb → intridea/changelog_line_parser_spec.rb} +1 -1
  35. data/spec/{changelog_placeholder_line_spec.rb → intridea/changelog_placeholder_line_spec.rb} +5 -3
  36. data/spec/intridea/changelog_spec.rb +150 -0
  37. data/spec/{fixtures/changelogs → intridea/fixtures}/dates.md +3 -0
  38. data/spec/intridea/fixtures/extra_trailing_space.md +3 -0
  39. data/spec/keep_a_changelog/changelog_spec.rb +84 -0
  40. data/spec/keep_a_changelog/fixtures/invalid_line.md +23 -0
  41. data/spec/keep_a_changelog/fixtures/lines_with_links.md +14 -0
  42. data/spec/keep_a_changelog/fixtures/missing_a_version_header.md +20 -0
  43. data/spec/plugin_spec.rb +10 -0
  44. metadata +50 -173
  45. data/.travis.yml +0 -14
  46. data/spec/changelog_file_spec.rb +0 -110
  47. /data/spec/{fixtures/changelogs → intridea/fixtures}/customized.md +0 -0
  48. /data/spec/{fixtures/changelogs → intridea/fixtures}/imbalanced.md +0 -0
  49. /data/spec/{fixtures/changelogs → intridea/fixtures}/lines.md +0 -0
  50. /data/spec/{fixtures/changelogs → intridea/fixtures}/minimal.md +0 -0
  51. /data/spec/{fixtures/changelogs → intridea/fixtures}/missing_your_contribution_here.md +0 -0
  52. /data/spec/{fixtures/changelogs → intridea/fixtures}/semver.md +0 -0
  53. /data/spec/{fixtures/changelogs/keep_a_changelog.md → keep_a_changelog/fixtures/complete.md} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dda179f0ffebc733fa943723d9b16c6db3720beab1e5c43ee57746cb6f20577
4
- data.tar.gz: b1797cb0bd4d0eef3aead4e9a0409c057205d995efc3d56f200f106055900fe9
3
+ metadata.gz: 03270bfff2f0983bbf17c710358dfb6850d727f28afa131593deaed8c6824c0f
4
+ data.tar.gz: 8723e715d8f3f357e3d72d8e181c3d9174085de6c32ea79a87fbdbcf61160085
5
5
  SHA512:
6
- metadata.gz: 897e573a11db0076fd9c7bb745b5c8f39d47d94f4d2b69b298a1565cade582a9aaadf17d0667b48a1d9569bc0566558000e9baaec7bf9a6054d4818ed5475f1d
7
- data.tar.gz: c92f5ae706ada26bb3006adffae2df8aef0b79de05d1f6464257918004511a7bdc926a2430c6386d32961df4011c3e48b29162dea763a98865087e6df8fd4375
6
+ metadata.gz: 21fe62c2ce3142983ad12dcdee2dca0e3e1246ed376924619dba25151bd4556608f978d1e1b2225a9cfc5ae548eca5302e48a589b1e70711fafc01f759a09d2e
7
+ data.tar.gz: 02c819d7ec4819b83c76c146778beb44f9a9c716726113d41d5cbaee70523ca91ed0c137b5dd92c52540b34a1e24faaa8dab846f73ea72c4cbd73a99e2232d22
@@ -0,0 +1,23 @@
1
+ name: Danger
2
+ on:
3
+ pull_request:
4
+ types: [ opened, reopened, edited, synchronize ]
5
+ jobs:
6
+ danger:
7
+ name: Danger
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - name: Checkout
11
+ uses: actions/checkout@v3
12
+ with:
13
+ fetch-depth: 0
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.7
18
+ bundler-cache: true
19
+ - name: Run Danger
20
+ run: |
21
+ # the personal token is public, this is ok, base64 encode to avoid tripping Github
22
+ TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
23
+ DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
@@ -0,0 +1,16 @@
1
+ name: Lint
2
+ on: [ push, pull_request ]
3
+ jobs:
4
+ rubocop:
5
+ name: RuboCop
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Checkout
9
+ uses: actions/checkout@v3
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7
14
+ bundler-cache: true
15
+ - name: RuboCop
16
+ run: bundle exec rubocop
@@ -0,0 +1,20 @@
1
+ name: Test
2
+ on: [ push, pull_request ]
3
+ jobs:
4
+ test:
5
+ name: Test (Ruby ${{ matrix.ruby-version }})
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ ruby-version: [ '2.7' ]
11
+ steps:
12
+ - name: Checkout
13
+ uses: actions/checkout@v3
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ bundler-cache: true
19
+ - name: Run test
20
+ run: bundle exec rake spec
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pkg
3
3
  .idea/
4
4
  Gemfile.lock
5
5
  .yardoc
6
+ vendor/bundle
data/.rubocop.yml CHANGED
@@ -14,4 +14,14 @@ Metrics:
14
14
  Metrics/LineLength:
15
15
  Max: 256
16
16
 
17
+ Style/FrozenStringLiteralComment:
18
+ Enabled: false
19
+
20
+ Naming/PredicateName:
21
+ Enabled: true
22
+ NameWhitelist:
23
+ - is_a?
24
+ - have_you_updated_changelog?
25
+ - is_changelog_format_correct?
26
+
17
27
  inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml CHANGED
@@ -1,45 +1,7 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-07-28 16:00:45 -0400 using RuboCop version 0.61.1.
3
+ # on 2020-05-08 17:23:39 -0400 using RuboCop version 0.73.0.
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
7
7
  # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 2
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: EnforcedStyle.
12
- # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
13
- Layout/IndentHeredoc:
14
- Exclude:
15
- - 'lib/changelog/plugin.rb'
16
-
17
- # Offense count: 1
18
- # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
19
- Lint/UselessAccessModifier:
20
- Exclude:
21
- - 'lib/changelog/changelog_line/changelog_line_parser.rb'
22
-
23
- # Offense count: 2
24
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
25
- # NamePrefix: is_, has_, have_
26
- # NamePrefixBlacklist: is_, has_, have_
27
- # NameWhitelist: is_a?
28
- # MethodDefinitionMacros: define_method, define_singleton_method
29
- Naming/PredicateName:
30
- Exclude:
31
- - 'spec/**/*'
32
- - 'lib/changelog/plugin.rb'
33
-
34
- # Offense count: 1
35
- Style/DoubleNegation:
36
- Exclude:
37
- - 'lib/changelog/changelog_file.rb'
38
-
39
- # Offense count: 1
40
- # Cop supports --auto-correct.
41
- # Configuration parameters: EnforcedStyle.
42
- # SupportedStyles: module_function, extend_self
43
- Style/ModuleFunction:
44
- Exclude:
45
- - 'lib/changelog/config.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.7.0 (2023/11/21)
4
+
5
+ * [#62](https://github.com/dblock/danger-changelog/pull/62): Migrate CI from Travis to GitHub Actions - [@mathroule](https://github.com/mathroule).
6
+ * [#61](https://github.com/dblock/danger-changelog/pull/61): Add support for ISO date & time - [@mathroule](https://github.com/mathroule).
7
+
8
+ ### 0.6.1 (2020/05/08)
9
+
10
+ * [#33](https://github.com/dblock/danger-changelog/issues/33): Attempt to point out known problems in Intridea format - [@dblock](https://github.com/dblock).
11
+ * [#51](https://github.com/dblock/danger-changelog/pull/51): Allow markdown links in keep-a-changelog lines - [@dblock](https://github.com/dblock).
12
+ * [#50](https://github.com/dblock/danger-changelog/pull/50): Added TOC to README - [@dblock](https://github.com/dblock).
13
+
3
14
  ### 0.6.0 (2019/07/28)
4
15
 
5
16
  * [#47](https://github.com/dblock/danger-changelog/pull/47): Configure `Config#placeholder_line` at plugin level - [@dblock](https://github.com/dblock).
data/CONTRIBUTING.md CHANGED
@@ -114,7 +114,7 @@ git push origin my-feature-branch -f
114
114
 
115
115
  ### Check on Your Pull Request
116
116
 
117
- Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
117
+ Go back to your pull request after a few minutes and see whether it passed muster with GitHub Actions. Everything should look green, otherwise fix issues and amend your commit as described above.
118
118
 
119
119
  ### Be Patient
120
120
 
data/Dangerfile CHANGED
@@ -1,3 +1,4 @@
1
1
  # danger.systems
2
2
 
3
+ toc.check!
3
4
  changelog.check!
data/Gemfile CHANGED
@@ -1,3 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :development, :test do
6
+ gem 'activesupport'
7
+ gem 'bundler'
8
+ gem 'danger-toc', '~> 0.2.0'
9
+ gem 'guard', '~> 2.14'
10
+ gem 'guard-rspec', '~> 4.7'
11
+ gem 'listen', '3.0.7'
12
+ gem 'pry'
13
+ gem 'rake', '~> 10.0'
14
+ gem 'rspec', '~> 3.4'
15
+ gem 'rubocop', '~> 0.73.0'
16
+ gem 'yard', '~> 0.9.11'
17
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 Daniel Doubrovkine <dblock@dblock.org>
1
+ Copyright (c) 2016-2019 Daniel Doubrovkine <dblock@dblock.org>
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,10 +1,27 @@
1
- # danger-changelog
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
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
- [![Build Status](https://travis-ci.org/dblock/danger-changelog.svg?branch=master)](https://travis-ci.org/dblock/danger-changelog)
7
+ [![Build Status](https://github.com/dblock/danger-changelog/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/dblock/danger-changelog/actions/workflows/test.yml)
8
+
9
+ # Table of Contents
10
+
11
+ - [What’s a correctly formatted CHANGELOG file?](#whats-a-correctly-formatted-changelog-file)
12
+ - [Installation](#installation)
13
+ - [Usage](#usage)
14
+ - [Configuration](#configuration)
15
+ - [changelog.filename](#changelogfilename)
16
+ - [changelog.format](#changelogformat)
17
+ - [changelog.placeholder_line](#changelogplaceholder_line)
18
+ - [changelog.ignore_files](#changelogignore_files)
19
+ - [Checks](#checks)
20
+ - [changelog.check!](#changelogcheck)
21
+ - [changelog.have_you_updated_changelog?](#changeloghave_you_updated_changelog)
22
+ - [changelog.is_changelog_format_correct?](#changelogis_changelog_format_correct)
23
+ - [Contributing](#contributing)
24
+ - [Copyright](#copyright)
8
25
 
9
26
  ## What's a correctly formatted CHANGELOG file?
10
27
 
@@ -90,6 +107,6 @@ See [CONTRIBUTING](CONTRIBUTING.md).
90
107
 
91
108
  ## Copyright
92
109
 
93
- Copyright (c) Daniel Doubrovkine, 2016
110
+ Copyright (c) Daniel Doubrovkine, 2016-2019
94
111
 
95
112
  MIT License, see [LICENSE](LICENSE.txt) for details.
data/RELEASING.md CHANGED
@@ -11,7 +11,7 @@ bundle install
11
11
  rake
12
12
  ```
13
13
 
14
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/danger-changelog) for all supported platforms.
14
+ Check that the last build succeeded in [GitHub Actions](https://github.com/dblock/danger-changelog/actions) for all supported platforms.
15
15
 
16
16
  Increment the version, modify [lib/changelog/gem_version.rb](lib/changelog/gem_version.rb).
17
17
 
@@ -18,15 +18,4 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
21
-
22
- spec.add_development_dependency 'activesupport'
23
- spec.add_development_dependency 'bundler'
24
- spec.add_development_dependency 'guard', '~> 2.14'
25
- spec.add_development_dependency 'guard-rspec', '~> 4.7'
26
- spec.add_development_dependency 'listen', '3.0.7'
27
- spec.add_development_dependency 'pry'
28
- spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.4'
30
- spec.add_development_dependency 'rubocop', '~> 0.61.1'
31
- spec.add_development_dependency 'yard', '~> 0.9.11'
32
21
  end
@@ -14,8 +14,10 @@ module Danger
14
14
  parser.add_listener(self)
15
15
  end
16
16
 
17
- def add_bad_line(line)
18
- @bad_lines << line
17
+ def add_bad_line(line, detail = nil)
18
+ return unless line || detail
19
+
20
+ @bad_lines << [line, detail].compact
19
21
  end
20
22
 
21
23
  def add_global_failure(message)
@@ -38,7 +40,7 @@ module Danger
38
40
  end
39
41
 
40
42
  def exists?
41
- !!@exists
43
+ @exists
42
44
  end
43
45
 
44
46
  def bad?
@@ -5,10 +5,26 @@ 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
+ return validation_result.valid? if validation_result
9
+
10
+ @validation_result = Parsers::ValidationResult.new
11
+
12
+ validation_result.error! 'too many parenthesis' unless balanced?(line)
13
+ return false if validation_result.invalid?
14
+
9
15
  return true if line =~ %r{^\*\s[\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
10
16
  return true if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
11
17
 
18
+ validation_result.error! 'does not start with a star' unless ChangelogEntryLine.starts_with_star?(line)
19
+ validation_result.error! 'does not include a pull request link' unless ChangelogEntryLine.with_pr_link?(line)
20
+ validation_result.error! 'does not have a description' unless ChangelogEntryLine.with_changelog_description?(line)
21
+ validation_result.error! 'does not include an author link' unless ChangelogEntryLine.with_author_link?(line)
22
+ validation_result.error! 'has an extra trailing space' if ChangelogEntryLine.ends_with_space?(line)
23
+ validation_result.error! 'is missing a period at the end of the line' unless ChangelogEntryLine.ends_with_period?(line)
24
+ validation_result.error! 'has an extra period or comma at the end of the description' if
25
+ line =~ %r{^\*\s[\`[:upper:]].*[.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$} ||
26
+ line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].*[.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
27
+
12
28
  false
13
29
  end
14
30
 
@@ -40,6 +56,20 @@ module Danger
40
56
  false
41
57
  end
42
58
 
59
+ # checks whether line ends with a space
60
+ def self.ends_with_space?(line)
61
+ return true if line =~ /[[:blank:]]\n$/
62
+
63
+ false
64
+ end
65
+
66
+ # checks whether line ends with a period
67
+ def self.ends_with_period?(line)
68
+ return true if line =~ /\.\n$/
69
+
70
+ false
71
+ end
72
+
43
73
  # checks whether line contains a MARKDOWN link to a PR
44
74
  def self.with_pr_link?(line)
45
75
  return true if line =~ %r{\[\#\d+\]\(http[s]?:\/\/github\.com\/.*\d+[\/]?\)}
@@ -7,14 +7,14 @@ module Danger
7
7
 
8
8
  HASHES = /\#{1,4}/.freeze
9
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
10
+ ISO8601_DATETIME = %r{(?<datetime>([0-9]{4})[-/]?(1[0-2]|0?[1-9])[-/]+(3[01]|0?[1-9]|[12][0-9])(T[0-9]{2}:[0-9]{2}:[0-9]{2})?Z?)}.freeze
11
11
 
12
12
  def valid?
13
13
  stripped_line = line.strip
14
14
 
15
15
  m = stripped_line.match(/^#{HASHES}\s#{OPEN_PARENS}[\w\s\:]*#{CLOSE_PARENS}$/) # title
16
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
17
+ m ||= stripped_line.match(/^#{HASHES}\s#{OPEN_PARENS}#{SEMVER}#{CLOSE_PARENS}[\s\-]+#{OPEN_PARENS}(#{ISO8601_DATETIME}|\w*)#{CLOSE_PARENS}$/) # semver and ISO 8601 date & time or next version description
18
18
 
19
19
  !m.nil? && balanced?(stripped_line)
20
20
  end
@@ -7,9 +7,11 @@ module Danger
7
7
  DELIMITER = /[(){}\[\]]/.freeze
8
8
 
9
9
  attr_accessor :line
10
+ attr_accessor :validation_result
10
11
 
11
12
  def initialize(line)
12
13
  self.line = line
14
+ self.validation_result = nil
13
15
  end
14
16
 
15
17
  # Match the line with the validation rules
@@ -16,12 +16,12 @@ module Danger
16
16
  changelog_line_class.new(line)
17
17
  end
18
18
 
19
- private_class_method
20
-
21
19
  def self.available_changelog_lines
22
20
  # Order is important
23
21
  [ChangelogPlaceholderLine, ChangelogEntryLine, ChangelogHeaderLine]
24
22
  end
23
+
24
+ private_class_method :available_changelog_lines
25
25
  end
26
26
  end
27
27
  end
@@ -1,7 +1,7 @@
1
1
  module Danger
2
2
  module Changelog
3
3
  module Config
4
- extend self
4
+ module_function
5
5
 
6
6
  ATTRIBUTES = %i[
7
7
  placeholder_line
@@ -14,7 +14,9 @@ module Danger
14
14
 
15
15
  DELEGATORS = ATTRIBUTES + ACCESSORS
16
16
 
17
- attr_accessor(*Config::ATTRIBUTES)
17
+ class << self
18
+ attr_accessor(*Config::ATTRIBUTES)
19
+ end
18
20
 
19
21
  def placeholder_line=(value)
20
22
  if value
@@ -1,3 +1,3 @@
1
1
  module Changelog
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
@@ -14,8 +14,8 @@ module Danger
14
14
 
15
15
  private
16
16
 
17
- def notify_of_bad_line(message)
18
- listeners.each { |changelog| changelog.add_bad_line(message) }
17
+ def notify_of_bad_line(message, detail = nil)
18
+ listeners.each { |changelog| changelog.add_bad_line(message, detail) }
19
19
  end
20
20
 
21
21
  def notify_of_global_failure(message)
@@ -18,7 +18,8 @@ module Danger
18
18
  changelog_line = ChangelogLineParser.parse(line)
19
19
 
20
20
  if changelog_line.nil? || changelog_line.invalid?
21
- notify_of_bad_line line
21
+ detail = changelog_line.validation_result.to_s if changelog_line.validation_result&.invalid?
22
+ notify_of_bad_line line, detail
22
23
  next
23
24
  end
24
25
 
@@ -16,7 +16,7 @@ module Danger
16
16
  notify_of_global_failure(
17
17
  'The changelog is missing the version header for the Keep A ' \
18
18
  'Changelog format. See <https://keepachangelog.com> to see ' \
19
- 'the format of the header'
19
+ 'the format of the header.'
20
20
  )
21
21
  end
22
22
 
@@ -42,7 +42,7 @@ module Danger
42
42
  lines.each do |line|
43
43
  line = line.chomp
44
44
 
45
- if /##?[^#]/.match?(line)
45
+ if /^##?[^#]/.match?(line)
46
46
  blocks << block.dup unless block.empty?
47
47
  block.clear
48
48
  end
@@ -0,0 +1,31 @@
1
+ module Danger
2
+ module Changelog
3
+ module Parsers
4
+ class ValidationResult
5
+ def initialize
6
+ @errors = []
7
+ end
8
+
9
+ attr_reader :errors
10
+
11
+ def valid?
12
+ errors.empty?
13
+ end
14
+
15
+ def invalid?
16
+ !valid?
17
+ end
18
+
19
+ def error!(message)
20
+ errors << message
21
+ end
22
+
23
+ def to_s
24
+ return nil if valid?
25
+
26
+ errors.join(', ')
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,5 @@
1
1
  require 'changelog/parsers/base'
2
+ require 'changelog/parsers/validation_result'
2
3
  require 'changelog/parsers/intridea_format'
3
4
  require 'changelog/parsers/keep_a_changelog'
4
5
 
@@ -75,15 +75,16 @@ module Danger
75
75
  if changelog_file.exists?
76
76
  changelog_file.parse
77
77
  changelog_file.bad_lines.each do |line|
78
- markdown <<-MARKDOWN
79
- ```markdown
80
- #{line}```
78
+ markdown <<~MARKDOWN
79
+ ```markdown
80
+ #{line.map(&:strip).join("\n")}
81
+ ```
81
82
  MARKDOWN
82
83
  end
83
84
  messaging.fail(parser.bad_line_message(filename), sticky: false) if changelog_file.bad_lines?
84
85
 
85
86
  changelog_file.global_failures.each do |failure|
86
- messaging.fail(failure, sticy: false)
87
+ messaging.fail(failure, sticky: false)
87
88
  end
88
89
 
89
90
  changelog_file.good?
@@ -96,12 +97,12 @@ module Danger
96
97
  private
97
98
 
98
99
  def warn_update_changelog
99
- markdown <<-MARKDOWN
100
- Here's an example of a #{filename} entry:
100
+ markdown <<~MARKDOWN
101
+ Here's an example of a #{filename} entry:
101
102
 
102
- ```markdown
103
- #{Danger::Changelog::ChangelogEntryLine.example(github)}
104
- ```
103
+ ```markdown
104
+ #{Danger::Changelog::ChangelogEntryLine.example(github)}
105
+ ```
105
106
  MARKDOWN
106
107
  warn "Unless you're refactoring existing code or improving documentation, please update #{filename}.", sticky: false
107
108
  end