Skip to content

Commit 9eae9c3

Browse files
Accept username as valid author name in CHANGELOG
This fixes the `CHANGELOG` linter to accept usernames that include digits as valid author names.
1 parent 404ce7e commit 9eae9c3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tools/rail_inspector/lib/rail_inspector/changelog.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def validate_authors
3939
return if no_changes?
4040

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

4444
return if authors
4545

tools/rail_inspector/test/rail_inspector/changelog_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def test_entries_without_author_are_invalid
1818
assert_equal 2, offenses.length
1919
end
2020

21+
def test_valid_username_is_valid_author
22+
assert_valid_entry <<~CHANGELOG
23+
* Cool change.
24+
25+
*1337-rails-c0d3r*
26+
CHANGELOG
27+
end
28+
2129
def test_parses_with_extra_newlines
2230
@changelog = changelog_fixture("action_mailbox_83d85b2.md")
2331

@@ -126,6 +134,11 @@ def offenses
126134
entries.flat_map(&:offenses)
127135
end
128136

137+
def assert_valid_entry(source)
138+
entry = RailInspector::Changelog::Entry.new(source.lines(chomp: true), 1)
139+
assert_empty entry.offenses, "Entry has offenses"
140+
end
141+
129142
ANNOTATION_PATTERN = /\s*\^+ /
130143

131144
def assert_offense(source)

0 commit comments

Comments
 (0)