Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept username as valid author name in CHANGELOG #49919

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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