Skip to content

Commit

Permalink
Fix duplicate contributor names when generating changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Sep 20, 2023
1 parent 5395638 commit a54d905
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion spec/tasks/changelog_spec.rb
Expand Up @@ -41,10 +41,14 @@
CHANGELOG
end

let(:duplicate_entry) do
Changelog::Entry.new(type: :fix, body: 'Duplicate contributor name entry', user: 'johndoe')
end

let(:entries) do
%i[fix new fix].map.with_index do |type, i|
Changelog::Entry.new(type: type, body: "Do something cool#{'x' * i}", user: "johndoe#{'x' * i}")
end
end << duplicate_entry
end
let(:entry) { entries.first }

Expand Down Expand Up @@ -72,6 +76,7 @@
* [#x](https://github.com/rubocop/rubocop-ast/pull/x): Do something cool. ([@johndoe][])
* [#x](https://github.com/rubocop/rubocop-ast/pull/x): Do something coolxx. ([@johndoexx][])
* [#x](https://github.com/rubocop/rubocop-ast/pull/x): Duplicate contributor name entry. ([@johndoe][])
CHANGELOG

expect(changelog.new_contributor_lines).to eq(
Expand Down
6 changes: 3 additions & 3 deletions tasks/changelog.rb
Expand Up @@ -134,9 +134,9 @@ def merge_content
end

def new_contributor_lines
contributors
.map { |user| format(CONTRIBUTOR, user: user) }
.reject { |line| @rest.include?(line) }
unique_contributor_names = contributors.map { |user| format(CONTRIBUTOR, user: user) }.uniq

unique_contributor_names.reject { |line| @rest.include?(line) }
end

def contributors
Expand Down

0 comments on commit a54d905

Please sign in to comment.