Skip to content

Commit a54d905

Browse files
committed
Fix duplicate contributor names when generating changelog
Follow up rubocop/rubocop@2d4b944
1 parent 5395638 commit a54d905

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

spec/tasks/changelog_spec.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@
4141
CHANGELOG
4242
end
4343

44+
let(:duplicate_entry) do
45+
Changelog::Entry.new(type: :fix, body: 'Duplicate contributor name entry', user: 'johndoe')
46+
end
47+
4448
let(:entries) do
4549
%i[fix new fix].map.with_index do |type, i|
4650
Changelog::Entry.new(type: type, body: "Do something cool#{'x' * i}", user: "johndoe#{'x' * i}")
47-
end
51+
end << duplicate_entry
4852
end
4953
let(:entry) { entries.first }
5054

@@ -72,6 +76,7 @@
7276
7377
* [#x](https://github.com/rubocop/rubocop-ast/pull/x): Do something cool. ([@johndoe][])
7478
* [#x](https://github.com/rubocop/rubocop-ast/pull/x): Do something coolxx. ([@johndoexx][])
79+
* [#x](https://github.com/rubocop/rubocop-ast/pull/x): Duplicate contributor name entry. ([@johndoe][])
7580
CHANGELOG
7681

7782
expect(changelog.new_contributor_lines).to eq(

tasks/changelog.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def merge_content
134134
end
135135

136136
def new_contributor_lines
137-
contributors
138-
.map { |user| format(CONTRIBUTOR, user: user) }
139-
.reject { |line| @rest.include?(line) }
137+
unique_contributor_names = contributors.map { |user| format(CONTRIBUTOR, user: user) }.uniq
138+
139+
unique_contributor_names.reject { |line| @rest.include?(line) }
140140
end
141141

142142
def contributors

0 commit comments

Comments
 (0)