Skip to content

Commit

Permalink
Merge pull request #49919 from jonathanhefner/linter-accept-username-…
Browse files Browse the repository at this point in the history
…as-author

Accept username as valid author name in `CHANGELOG`
  • Loading branch information
eileencodes committed Nov 7, 2023
1 parent 55f4a62 commit d969751
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -39,7 +39,7 @@ def validate_authors
return if no_changes?

authors =
lines.reverse.find { |line| line.match?(/\*[^\d\s]+(\s[^\d\s]+)*\*/) }
lines.reverse.find { |line| line.match?(/^ *\*[^*\s].*[^*\s]\*$/) }

return if authors

Expand Down
13 changes: 13 additions & 0 deletions tools/rail_inspector/test/rail_inspector/changelog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ def test_entries_without_author_are_invalid
assert_equal 2, offenses.length
end

def test_valid_username_is_valid_author
assert_valid_entry <<~CHANGELOG
* Cool change.
*1337-rails-c0d3r*
CHANGELOG
end

def test_parses_with_extra_newlines
@changelog = changelog_fixture("action_mailbox_83d85b2.md")

Expand Down Expand Up @@ -126,6 +134,11 @@ def offenses
entries.flat_map(&:offenses)
end

def assert_valid_entry(source)
entry = RailInspector::Changelog::Entry.new(source.lines(chomp: true), 1)
assert_empty entry.offenses, "Entry has offenses"
end

ANNOTATION_PATTERN = /\s*\^+ /

def assert_offense(source)
Expand Down

0 comments on commit d969751

Please sign in to comment.