From e1e5de555b103cad1150d94b62155ab79ec443e6 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 19 Nov 2014 17:28:49 +0200 Subject: [PATCH] Issues for last tag not in list --- lib/github_changelog_generator.rb | 31 ++++++++++++------------ lib/github_changelog_generator/parser.rb | 6 ----- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 22ae517..0e8bf8d 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -15,6 +15,12 @@ module GitHubChangelogGenerator @options = Parser.parse_options + if options[:verbose] + puts 'Input options:' + pp options + puts '' + end + github_token if @github_token.nil? @@ -39,7 +45,7 @@ module GitHubChangelogGenerator end def exec_command(cmd) - exec_cmd = "cd #{$project_path} && #{cmd}" + exec_cmd = "cd #{$project_path} and #{cmd}" %x[#{exec_cmd}] end @@ -104,7 +110,7 @@ module GitHubChangelogGenerator if @options[:last] log += self.generate_log_between_tags(self.all_tags[0], self.all_tags[1]) - elsif @options[:tag1] && @options[:tag2] + elsif @options[:tag1] and @options[:tag2] tag1 = @options[:tag1] tag2 = @options[:tag2] @@ -222,23 +228,23 @@ module GitHubChangelogGenerator end def delete_by_time(array, hash_key, newer_tag_time, older_tag_time = nil) - array_new = Array.new(array) - array_new.delete_if { |req| + array.select { |req| if req[hash_key] t = Time.parse(req[hash_key]).utc if older_tag_time.nil? - tag_is_older_of_older = true + tag_in_range_old = true else - tag_is_older_of_older = t > older_tag_time + tag_in_range_old = t > older_tag_time end - tag_is_newer_than_new = t <= newer_tag_time + tag_in_range_new = t <= newer_tag_time - tag_not_in_range = (tag_is_older_of_older) && (tag_is_newer_than_new) - !tag_not_in_range + tag_in_range = (tag_in_range_old) && (tag_in_range_new) + + tag_in_range else - true + false end } end @@ -340,13 +346,8 @@ module GitHubChangelogGenerator def get_all_issues - if @options[:verbose] - puts 'Fetching closed issues..' - end - response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil - issues = [] response.each_page do |page| issues.concat(page) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index b85449f..584b641 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -61,12 +61,6 @@ module GitHubChangelogGenerator parser.parse! - if options[:verbose] - puts 'Input options:' - pp options - puts '' - end - #udefined case with 1 parameter: if ARGV[0] && !ARGV[1] puts parser.banner