From 5f6756e8dd5c33624abc4388ca6844927cb57f10 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Tue, 24 Mar 2015 13:43:16 +0200 Subject: [PATCH] Add warrning in case of 0 tags in repo. Fix #208. Reformat + prettify output. --- lib/github_changelog_generator.rb | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 84e6cee..30a9b46 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -16,7 +16,7 @@ module GitHubChangelogGenerator PER_PAGE_NUMBER = 30 GH_RATE_LIMIT_EXCEEDED_MSG = 'Warning: GitHub API rate limit exceed (5000 per hour), change log may not ' + - 'contain some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument' + 'contain some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument' def initialize @@ -101,7 +101,7 @@ module GitHubChangelogGenerator end issue[:actual_date] = commit[:author][:date] rescue - puts "Warning: can't fetch commit #{event[:commit_id]} probably it referenced from another repo." + puts "Warning: can't fetch commit #{event[:commit_id]} probably it referenced from another repo.".yellow issue[:actual_date] = issue[:closed_at] end end @@ -153,7 +153,7 @@ module GitHubChangelogGenerator self.fetch_merged_at_pull_requests - filtered_pull_requests = @pull_requests.select {|pr| pr[:merged_at] != nil } + filtered_pull_requests = @pull_requests.select { |pr| pr[:merged_at] != nil } unless @options[:include_labels].nil? filtered_pull_requests = @pull_requests.select { |issue| @@ -285,7 +285,7 @@ module GitHubChangelogGenerator threads.each { |thr| thr.join } if @options[:verbose] - puts 'Fetching tags: Done!' + puts "Fetching tags dates: #{i} Done!" end end @@ -316,6 +316,11 @@ module GitHubChangelogGenerator if @options[:verbose] puts "Found #{tags.count} tags" end + + if tags.count == 0 + puts "Warning: Can't find any tags in repo. Make sure, that you push tags to remote repo via 'git push --tags'".yellow + end + rescue puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow end @@ -623,12 +628,7 @@ module GitHubChangelogGenerator fetch_events_async(@issues + @pull_requests) - #to clear line from prev print - print " \r" - if @options[:verbose] - puts 'Fetching events for issues and PR: Done!' - end end def fetch_events_async(issues) @@ -651,6 +651,14 @@ module GitHubChangelogGenerator threads.each { |thr| thr.join } threads = [] } + + #to clear line from prev print + print " \r" + + if @options[:verbose] + puts "Fetching events for issues and PR: #{i} Done!" + end + end end