Skip to content

Commit

Permalink
Fix changelog linter to not run indefinitely on invalid changelogs
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Oct 13, 2023
1 parent a68f1a5 commit 3ca2f98
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/rail_inspector/lib/rail_inspector/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def peek_release_header?

def parse_release_header
@buffer.scan(
/#{RELEASE_HEADER} .*##\n\n/o
/#{RELEASE_HEADER} .*##\s*/o
)
end

Expand Down
47 changes: 47 additions & 0 deletions tools/rail_inspector/test/fixtures/action_mailbox_invalid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Rails 7.1.0.rc1 (September 13, 2023) ##

* No changes.


## 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 `<p>`. 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 })
# <p>Hello World</p>
```

*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*
9 changes: 9 additions & 0 deletions tools/rail_inspector/test/rail_inspector/changelog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ def test_no_changes_not_treated_as_offense
assert_equal 0, offenses.length
end

def test_invalid_header_does_not_cause_infinite_loop
Timeout.timeout(1) do
@changelog = changelog_fixture("action_mailbox_invalid.md")
assert_equal 2, offenses.length
end
rescue Timeout::Error
flunk "Parsing action_mailbox_invalid.md took too long"
end

def test_validate_authors
assert_offense(<<~CHANGELOG)
* Fix issue in CHANGELOG linting
Expand Down

0 comments on commit 3ca2f98

Please sign in to comment.