From 6a732ceb992667fbcecf6205efd2d5339d273fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 27 Aug 2015 13:30:16 +0200 Subject: [PATCH] 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] --- lib/github_changelog_generator/generator/generator.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator/generator/generator.rb b/lib/github_changelog_generator/generator/generator.rb index 2145766..68b6266 100644 --- a/lib/github_changelog_generator/generator/generator.rb +++ b/lib/github_changelog_generator/generator/generator.rb @@ -120,22 +120,22 @@ module GitHubChangelogGenerator issues_a.push dict unless added end + added_pull_requests = [] pull_requests.each do |dict| - added = false dict.labels.each do |label| if @options[:bug_labels].include? label.name bugs_a.push dict - added = true + added_pull_requests.push dict next end if @options[:enhancement_labels].include? label.name enhancement_a.push dict - added = true + added_pull_requests.push dict next end end - pull_requests.delete(dict) if added end + added_pull_requests.each { |p| pull_requests.delete(p) } [bugs_a, enhancement_a, issues_a] end