From bdc4657e2c62fbd4180b952d166afd8e67603911 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 19 Nov 2014 14:56:08 +0200 Subject: [PATCH] add filter option --- lib/github_changelog_generator.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 4f7632c..9200457 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -61,6 +61,19 @@ module GitHubChangelogGenerator puts "Received all closed pull requests: #{pull_requests.count}" end + filtered_pull_requests = pull_requests.select { |pull_request| + #We need issue to fetch labels + issue = @github.issues.get @options[:user], @options[:project], pull_request.number + #compare is there any labels from @options[:labels] array + select_no_label = !issue.labels.map { |label| label.name }.any? + select_by_label = (issue.labels.map { |label| label.name } & @options[:labels]).any? + select_by_label | select_no_label + } + + if @options[:verbose] + puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}" + end + pull_requests end