Do not alter pull_requests while iterating on it
Deleting elements of an array while iterating on it results in never seeing the last element. > a = [1,2,3] => [1, 2, 3] > a.each do |e| > p a > a.delete(e) > end [1, 2, 3] [2, 3] => [2]
This commit is contained in:
parent
312fe3d45a
commit
6a732ceb99
|
@ -120,22 +120,22 @@ module GitHubChangelogGenerator
|
||||||
issues_a.push dict unless added
|
issues_a.push dict unless added
|
||||||
end
|
end
|
||||||
|
|
||||||
|
added_pull_requests = []
|
||||||
pull_requests.each do |dict|
|
pull_requests.each do |dict|
|
||||||
added = false
|
|
||||||
dict.labels.each do |label|
|
dict.labels.each do |label|
|
||||||
if @options[:bug_labels].include? label.name
|
if @options[:bug_labels].include? label.name
|
||||||
bugs_a.push dict
|
bugs_a.push dict
|
||||||
added = true
|
added_pull_requests.push dict
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if @options[:enhancement_labels].include? label.name
|
if @options[:enhancement_labels].include? label.name
|
||||||
enhancement_a.push dict
|
enhancement_a.push dict
|
||||||
added = true
|
added_pull_requests.push dict
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pull_requests.delete(dict) if added
|
|
||||||
end
|
end
|
||||||
|
added_pull_requests.each { |p| pull_requests.delete(p) }
|
||||||
|
|
||||||
[bugs_a, enhancement_a, issues_a]
|
[bugs_a, enhancement_a, issues_a]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user