From 296156033af33dd16367c9ee9de97213bdf69b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 13 Sep 2023 01:51:51 +0000 Subject: [PATCH] Support CHANGELOG with release headers in the linter --- .../lib/rail_inspector/changelog.rb | 17 ++++++++ .../test/fixtures/action_view.md | 41 +++++++++++++++++++ .../test/rail_inspector/changelog_test.rb | 6 +++ 3 files changed, 64 insertions(+) create mode 100644 tools/rail_inspector/test/fixtures/action_view.md diff --git a/tools/rail_inspector/lib/rail_inspector/changelog.rb b/tools/rail_inspector/lib/rail_inspector/changelog.rb index aace936efa..20f06092ca 100644 --- a/tools/rail_inspector/lib/rail_inspector/changelog.rb +++ b/tools/rail_inspector/lib/rail_inspector/changelog.rb @@ -115,6 +115,11 @@ def initialize(file) def parse until @buffer.eos? + if peek_release_header? + pop_entry + next parse_release_header + end + if peek_footer? pop_entry next parse_footer @@ -136,6 +141,18 @@ def parse_line FOOTER_TEXT = "Please check" + RELEASE_HEADER = "## Rails" + + def peek_release_header? + @buffer.peek(RELEASE_HEADER.length) == RELEASE_HEADER + end + + def parse_release_header + @buffer.scan( + /#{RELEASE_HEADER} .*##\n\n/o + ) + end + def parse_footer @buffer.scan( /#{FOOTER_TEXT} \[\d-\d-stable\]\(.*\) for previous changes\.\n/o diff --git a/tools/rail_inspector/test/fixtures/action_view.md b/tools/rail_inspector/test/fixtures/action_view.md new file mode 100644 index 0000000000..a77bda25dc --- /dev/null +++ b/tools/rail_inspector/test/fixtures/action_view.md @@ -0,0 +1,41 @@ +## Rails 7.1.0.beta1 (September 13, 2023) ## + +* Fix `simple_format` with blank `wrapper_tag` option returns plain html tag + + By default `simple_format` method returns the text wrapped with `

`. But if we explicitly specify + the `wrapper_tag: nil` in the options, it returns the text wrapped with `<>` tag. + + Before: + + ```ruby + simple_format("Hello World", {}, { wrapper_tag: nil }) + # <>Hello World + ``` + + After: + + ```ruby + simple_format("Hello World", {}, { wrapper_tag: nil }) + #

Hello World

+ ``` + + *Akhil G Krishnan*, *Junichi Ito* + +* Don't double-encode nested `field_id` and `field_name` index values + + Pass `index: @options` as a default keyword argument to `field_id` and + `field_name` view helper methods. + + *Sean Doyle* + +* Allow opting in/out of `Link preload` headers when calling `stylesheet_link_tag` or `javascript_include_tag` + + ```ruby + # will exclude header, even if setting is enabled: + javascript_include_tag("http://example.com/all.js", preload_links_header: false) + + # will include header, even if setting is disabled: + stylesheet_link_tag("http://example.com/all.js", preload_links_header: true) + ``` + + *Alex Ghiculescu* diff --git a/tools/rail_inspector/test/rail_inspector/changelog_test.rb b/tools/rail_inspector/test/rail_inspector/changelog_test.rb index 1458709d44..18b236d367 100644 --- a/tools/rail_inspector/test/rail_inspector/changelog_test.rb +++ b/tools/rail_inspector/test/rail_inspector/changelog_test.rb @@ -48,6 +48,12 @@ def test_header_ending_with_star_not_treated_as_author assert_equal 0, offenses.length end + def test_release_header_is_not_treated_as_offense + @changelog = changelog_fixture("action_view.md") + + assert_equal 0, offenses.length + end + def test_validate_authors assert_offense(<<~CHANGELOG) * Fix issue in CHANGELOG linting