From 1673677df0a69b36296ef7e5a9d2210700b9c802 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Sat, 4 Apr 2015 03:27:05 +0300 Subject: [PATCH 1/2] add docs. add fail statment --- lib/github_changelog_generator.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 27fbad5..d04be04 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -229,6 +229,8 @@ module GitHubChangelogGenerator puts "Generated log placed in #{`pwd`.strip!}/#{output_filename}" end + # The full cycle of generation for whole project + # @return [String] The complete change log def generate_log_for_all_tags fetch_tags_dates @@ -261,6 +263,7 @@ module GitHubChangelogGenerator log end + # Async fetching of all tags dates def fetch_tags_dates if @options[:verbose] print "Fetching tag dates...\r" @@ -529,10 +532,13 @@ module GitHubChangelogGenerator log end + # Try to find tag date in local hash. + # Otherwise fFetch tag time and put it to local hash file. + # @param [String] tag_name name of the tag + # @param [Hash] tag_times_hash the hash of tag times + # @return [Time] time of specified tag def get_time_of_tag(tag_name, tag_times_hash = @tag_times_hash) - if tag_name.nil? - return nil - end + fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil? if tag_times_hash[tag_name["name"]] return @tag_times_hash[tag_name["name"]] From 911b91c0abbf44bdc4d5329c59a7f74ccc63a899 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Sat, 4 Apr 2015 03:27:05 +0300 Subject: [PATCH 2/2] add docs. add fail statment --- lib/github_changelog_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index d04be04..1b2d62e 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -401,8 +401,8 @@ module GitHubChangelogGenerator def delete_by_time(array, hash_key = :actual_date, older_tag = nil, newer_tag = nil) fail ChangelogGeneratorError, "At least one of the tags should be not nil!".red if older_tag.nil? && newer_tag.nil? - newer_tag_time = get_time_of_tag(newer_tag) - older_tag_time = get_time_of_tag(older_tag) + newer_tag_time = newer_tag && get_time_of_tag(newer_tag) + older_tag_time = older_tag && get_time_of_tag(older_tag) array.select { |req| if req[hash_key]