Consistent print/put messages and style
This commit is contained in:
parent
2c8ba4965b
commit
c67909959b
|
@ -15,8 +15,8 @@ module GitHubChangelogGenerator
|
||||||
attr_accessor :options, :all_tags, :github
|
attr_accessor :options, :all_tags, :github
|
||||||
|
|
||||||
PER_PAGE_NUMBER = 30
|
PER_PAGE_NUMBER = 30
|
||||||
GH_RATE_LIMIT_EXCEEDED_MSG = 'Warning: GitHub API rate limit exceed (5000 per hour), change log may not ' \
|
GH_RATE_LIMIT_EXCEEDED_MSG = "Warning: GitHub API rate limit (5000 per hour) exceeded, change log may be " \
|
||||||
'contain some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument'
|
"missing some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument."
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@options = Parser.parse_options
|
@options = Parser.parse_options
|
||||||
|
@ -95,7 +95,7 @@ module GitHubChangelogGenerator
|
||||||
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
|
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
|
||||||
issue[:actual_date] = commit[:author][:date]
|
issue[:actual_date] = commit[:author][:date]
|
||||||
rescue
|
rescue
|
||||||
puts "Warning: can't fetch commit #{event[:commit_id]} probably it referenced from another repo.".yellow
|
puts "Warning: Can't fetch commit #{event[:commit_id]}. It is probably referenced from another repo.".yellow
|
||||||
issue[:actual_date] = issue[:closed_at]
|
issue[:actual_date] = issue[:closed_at]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -139,7 +139,7 @@ module GitHubChangelogGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts 'Fetching merged dates... Done!'
|
puts "Fetching merged dates: Done!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
output_filename = "#{@options[:output]}"
|
output_filename = "#{@options[:output]}"
|
||||||
File.open(output_filename, 'w') { |file| file.write(log) }
|
File.open(output_filename, 'w') { |file| file.write(log) }
|
||||||
puts 'Done!'
|
puts "Done!"
|
||||||
puts "Generated log placed in #{`pwd`.strip!}/#{output_filename}"
|
puts "Generated log placed in #{`pwd`.strip!}/#{output_filename}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -218,13 +218,13 @@ module GitHubChangelogGenerator
|
||||||
fetch_tags_dates
|
fetch_tags_dates
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts 'Sorting tags..'
|
puts "Sorting tags..."
|
||||||
end
|
end
|
||||||
|
|
||||||
@all_tags.sort_by! { |x| get_time_of_tag(x) }.reverse!
|
@all_tags.sort_by! { |x| get_time_of_tag(x) }.reverse!
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts 'Generating log..'
|
puts "Generating log..."
|
||||||
end
|
end
|
||||||
|
|
||||||
log = ''
|
log = ''
|
||||||
|
@ -248,7 +248,7 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
def fetch_tags_dates
|
def fetch_tags_dates
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
print "Fetching tags dates..\r"
|
print "Fetching tag dates...\r"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Async fetching tags:
|
# Async fetching tags:
|
||||||
|
@ -317,8 +317,8 @@ module GitHubChangelogGenerator
|
||||||
env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil)
|
env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil)
|
||||||
|
|
||||||
unless env_var
|
unless env_var
|
||||||
puts 'Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.'.yellow
|
puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow
|
||||||
puts 'This script can make only 50 requests to GitHub API per hour without token!'.yellow
|
puts "This script can make only 50 requests per hour to GitHub API without a token!".yellow
|
||||||
end
|
end
|
||||||
|
|
||||||
@github_token ||= env_var
|
@github_token ||= env_var
|
||||||
|
@ -382,7 +382,7 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)
|
def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)
|
||||||
fail 'At least one of the tags should be not nil!' if older_tag.nil? && newer_tag.nil?
|
fail "At least one of the tags should be not nil!" if older_tag.nil? && newer_tag.nil?
|
||||||
|
|
||||||
newer_tag_time = get_time_of_tag(newer_tag)
|
newer_tag_time = get_time_of_tag(newer_tag)
|
||||||
older_tag_time = get_time_of_tag(older_tag)
|
older_tag_time = get_time_of_tag(older_tag)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user