Merge branch 'release/1.11.0'

This commit is contained in:
Petr Korolev 2016-02-23 12:26:49 +02:00
commit 0a83b5ed5e
11 changed files with 89 additions and 105 deletions

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
github_changelog_generator (1.10.1)
github_changelog_generator (1.11.0)
colorize (~> 0.7)
github_api (~> 0.12)
@ -10,14 +10,11 @@ GEM
specs:
addressable (2.4.0)
ast (2.2.0)
astrolabe (1.3.1)
parser (~> 2.2)
codeclimate-test-reporter (0.4.8)
simplecov (>= 0.7.1, < 1.0.0)
colorize (0.7.7)
coveralls (0.8.10)
coveralls (0.8.11)
json (~> 1.8)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.11.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
@ -26,8 +23,6 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
github_api (0.13.1)
@ -38,53 +33,44 @@ GEM
multi_json (>= 1.7.5, < 2.0)
oauth2
hashie (3.4.3)
http-cookie (1.0.2)
domain_name (~> 0.5)
json (1.8.3)
jwt (1.5.2)
mime-types (2.99)
jwt (1.5.1)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
netrc (0.11.0)
oauth2 (1.0.0)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
parser (2.2.3.0)
ast (>= 1.1, < 3.0)
rack (>= 1.2, < 3)
parser (2.3.0.6)
ast (~> 2.2)
powerpack (0.1.1)
rack (1.6.4)
rainbow (2.0.0)
rake (10.4.2)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rainbow (2.1.0)
rake (10.5.0)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.1)
rspec-core (3.4.3)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.35.1)
astrolabe (~> 1.3)
parser (>= 2.2.3.0, < 3.0)
rubocop (0.37.2)
parser (>= 2.3.0.4, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
tins (<= 1.6.0)
unicode-display_width (~> 0.3)
ruby-progressbar (1.7.5)
simplecov (0.11.1)
simplecov (0.11.2)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
@ -94,9 +80,7 @@ GEM
thor (0.19.1)
thread_safe (0.3.5)
tins (1.6.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
unicode-display_width (0.3.1)
PLATFORMS
ruby
@ -112,4 +96,4 @@ DEPENDENCIES
simplecov (~> 0.10)
BUNDLED WITH
1.10.6
1.11.2

View File

@ -28,7 +28,7 @@ module GitHubChangelogGenerator
def run
log = @generator.compound_changelog
output_filename = "#{@options[:output]}"
output_filename = (@options[:output]).to_s
File.open(output_filename, "w") { |file| file.write(log) }
puts "Done!"
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"

View File

@ -7,11 +7,11 @@ module GitHubChangelogGenerator
class Fetcher
PER_PAGE_NUMBER = 30
CHANGELOG_GITHUB_TOKEN = "CHANGELOG_GITHUB_TOKEN"
CHANGELOG_GITHUB_TOKEN = "CHANGELOG_GITHUB_TOKEN".freeze
GH_RATE_LIMIT_EXCEEDED_MSG = "Warning: Can't finish operation: GitHub API rate limit exceeded, change log may be " \
"missing 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.".freeze
NO_TOKEN_PROVIDED = "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found. " \
"This script can make only 50 requests to GitHub API per hour without token!"
"This script can make only 50 requests to GitHub API per hour without token!".freeze
def initialize(options = {})
@options = options || {}
@ -123,12 +123,12 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
def fetch_closed_pull_requests
pull_requests = []
begin
if @options[:release_branch].nil?
response = @github.pull_requests.list @options[:user],
response = if @options[:release_branch].nil?
@github.pull_requests.list @options[:user],
@options[:project],
state: "closed"
else
response = @github.pull_requests.list @options[:user],
@github.pull_requests.list @options[:user],
@options[:project],
state: "closed",
base: @options[:release_branch]

View File

@ -12,10 +12,10 @@ module GitHubChangelogGenerator
log += @options[:frontmatter] if @options[:frontmatter]
log += "#{@options[:header]}\n\n"
if @options[:unreleased_only]
log += generate_log_between_tags(filtered_tags[0], nil)
log += if @options[:unreleased_only]
generate_log_between_tags(filtered_tags[0], nil)
else
log += generate_log_for_all_tags
generate_log_for_all_tags
end
log += File.read(@options[:base]) if File.file?(@options[:base])
@ -39,10 +39,10 @@ module GitHubChangelogGenerator
index2 = hash[tag2]
log += generate_log_between_tags(all_tags[index1], all_tags[index2])
else
fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
end
else
fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
end
log
end
@ -79,15 +79,15 @@ module GitHubChangelogGenerator
time_string = newer_tag_time.strftime @options[:date_format]
# Generate tag name and link
if @options[:release_url]
release_url = format(@options[:release_url], newer_tag_link)
release_url = if @options[:release_url]
format(@options[:release_url], newer_tag_link)
else
release_url = "#{project_url}/tree/#{newer_tag_link}"
"#{project_url}/tree/#{newer_tag_link}"
end
if newer_tag_name.equal? @options[:unreleased_label]
log += "## [#{newer_tag_name}](#{release_url})\n\n"
log += if newer_tag_name.equal? @options[:unreleased_label]
"## [#{newer_tag_name}](#{release_url})\n\n"
else
log += "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n"
"## [#{newer_tag_name}](#{release_url}) (#{time_string})\n"
end
if @options[:compare_link] && older_tag_link
@ -171,10 +171,10 @@ module GitHubChangelogGenerator
unless issue.pull_request.nil?
if @options[:author]
if issue.user.nil?
title_with_number += " ({Null user})"
title_with_number += if issue.user.nil?
" ({Null user})"
else
title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))"
" ([#{issue.user.login}](#{issue.user.html_url}))"
end
end
end

View File

@ -7,7 +7,7 @@ module GitHubChangelogGenerator
unless @options[:exclude_labels].nil?
issues = issues.select do |issue|
var = issue.labels.map(&:name) & @options[:exclude_labels]
!(var).any?
!var.any?
end
end
issues
@ -83,7 +83,7 @@ module GitHubChangelogGenerator
tag_in_range_new = tag_older_new_tag?(newer_tag_time, time)
tag_in_range = (tag_in_range_old) && (tag_in_range_new)
tag_in_range = tag_in_range_old && tag_in_range_new
tag_in_range
else
@ -93,19 +93,19 @@ module GitHubChangelogGenerator
end
def tag_older_new_tag?(newer_tag_time, time)
if newer_tag_time.nil?
tag_in_range_new = true
tag_in_range_new = if newer_tag_time.nil?
true
else
tag_in_range_new = time <= newer_tag_time
time <= newer_tag_time
end
tag_in_range_new
end
def tag_newer_old_tag?(older_tag_time, t)
if older_tag_time.nil?
tag_in_range_old = true
tag_in_range_old = if older_tag_time.nil?
true
else
tag_in_range_old = t > older_tag_time
t > older_tag_time
end
tag_in_range_old
end
@ -133,7 +133,7 @@ module GitHubChangelogGenerator
def filter_by_include_labels(issues)
filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue|
labels = issue.labels.map(&:name) & @options[:include_labels]
(labels).any?
labels.any?
end
filtered_issues
end

View File

@ -19,7 +19,7 @@ module GitHubChangelogGenerator
# @param [Hash] tag_name name of the tag
# @return [Time] time of specified tag
def get_time_of_tag(tag_name)
fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
name_of_tag = tag_name["name"]
time_for_name = @tag_times_hash[name_of_tag]
@ -58,7 +58,7 @@ module GitHubChangelogGenerator
if @since_tag.nil? && @options[:base] && File.file?(@options[:base])
reader = GitHubChangelogGenerator::Reader.new
content = reader.read(@options[:base])
@since_tag = content[0]["version"] if content
@since_tag = content[0]["version"] if content.count && content
end
@since_tag
end
@ -80,10 +80,10 @@ module GitHubChangelogGenerator
if tag
if all_tags.map(&:name).include? tag
idx = all_tags.index { |t| t.name == tag }
if idx > 0
filtered_tags = all_tags[0..idx - 1]
filtered_tags = if idx > 0
all_tags[0..idx - 1]
else
filtered_tags = []
[]
end
else
Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option."
@ -101,10 +101,10 @@ module GitHubChangelogGenerator
if (all_tags.count > 0) && (all_tags.map(&:name).include? tag)
idx = all_tags.index { |t| t.name == tag }
last_index = all_tags.count - 1
if idx > 0 && idx < last_index
filtered_tags = all_tags[idx + 1..last_index]
filtered_tags = if idx > 0 && idx < last_index
all_tags[idx + 1..last_index]
else
filtered_tags = []
[]
end
else
Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option."

View File

@ -3,13 +3,13 @@ module GitHubChangelogGenerator
module Helper
# @return true if the currently running program is a unit test
def self.test?
defined?SpecHelper
defined? SpecHelper
end
if test?
@log ||= Logger.new(nil) # don't show any logs when running tests
@log ||= if test?
Logger.new(nil) # don't show any logs when running tests
else
@log ||= Logger.new(STDOUT)
Logger.new(STDOUT)
end
@log.formatter = proc do |severity, _datetime, _progname, msg|
string = "#{msg}\n"

View File

@ -20,8 +20,8 @@ module GitHubChangelogGenerator
def parse_line!(line)
key_sym, value = extract_pair(line)
value = true if value =~ (/^(true|t|yes|y|1)$/i)
value = false if value =~ (/^(false|f|no|n|0)$/i)
value = true if value =~ /^(true|t|yes|y|1)$/i
value = false if value =~ /^(false|f|no|n|0)$/i
@options[key_sym] = value
rescue
raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""

View File

@ -17,7 +17,7 @@ module GitHubChangelogGenerator
between_tags exclude_tags since_tag max_issues
github_site github_endpoint simple_list
future_release release_branch verbose release_url
base )
base ).freeze
OPTIONS.each do |o|
attr_accessor o.to_sym
@ -37,7 +37,7 @@ module GitHubChangelogGenerator
def define(args, &task_block)
desc "Generate a Change log from GitHub"
task_block.call(*[self, args].slice(0, task_block.arity)) if task_block
yield(*[self, args].slice(0, task_block.arity)) if task_block
# clear any (auto-)pre-existing task
Rake::Task[@name].clear if Rake::Task.task_defined?(@name)
@ -57,7 +57,7 @@ module GitHubChangelogGenerator
log = generator.compound_changelog
output_filename = "#{options[:output]}"
output_filename = (options[:output]).to_s
File.open(output_filename, "w") { |file| file.write(log) }
puts "Done!"
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"

View File

@ -1,3 +1,3 @@
module GitHubChangelogGenerator
VERSION = "1.10.1"
VERSION = "1.11.0".freeze
end

View File

@ -1,8 +1,8 @@
VALID_TOKEN = "0123456789abcdef"
INVALID_TOKEN = "0000000000000000"
VALID_TOKEN = "0123456789abcdef".freeze
INVALID_TOKEN = "0000000000000000".freeze
DEFAULT_OPTIONS = { user: "skywinder",
project: "changelog_test" }
project: "changelog_test" }.freeze
def options_with_invalid_token
options = DEFAULT_OPTIONS