move compund to generator
This commit is contained in:
@@ -191,7 +191,7 @@ module GitHubChangelogGenerator
|
||||
# The entry point of this script to generate change log
|
||||
# @raise (ChangelogGeneratorError) Is thrown when one of specified tags was not found in list of tags.
|
||||
def run
|
||||
log = compound_changelog
|
||||
log = @generator.compound_changelog
|
||||
|
||||
output_filename = "#{@options[:output]}"
|
||||
File.open(output_filename, "w") { |file| file.write(log) }
|
||||
@@ -199,42 +199,6 @@ module GitHubChangelogGenerator
|
||||
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
|
||||
end
|
||||
|
||||
# Main function to start change log generation
|
||||
#
|
||||
# @return [String] Generated change log file
|
||||
def compound_changelog
|
||||
log = "# Change Log\n\n"
|
||||
|
||||
if @options[:unreleased_only]
|
||||
log += generate_log_between_tags(all_tags[0], nil)
|
||||
elsif @options[:tag1] and @options[:tag2]
|
||||
tag1 = @options[:tag1]
|
||||
tag2 = @options[:tag2]
|
||||
tags_strings = []
|
||||
all_tags.each { |x| tags_strings.push(x["name"]) }
|
||||
|
||||
if tags_strings.include?(tag1)
|
||||
if tags_strings.include?(tag2)
|
||||
to_a = tags_strings.map.with_index.to_a
|
||||
hash = Hash[to_a]
|
||||
index1 = hash[tag1]
|
||||
index2 = hash[tag2]
|
||||
log += generate_log_between_tags(all_tags[index1], all_tags[index2])
|
||||
else
|
||||
fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
|
||||
end
|
||||
else
|
||||
fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
|
||||
end
|
||||
else
|
||||
log += generate_log_for_all_tags
|
||||
end
|
||||
|
||||
log += "\n\n\\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
||||
@log = log
|
||||
@log = log
|
||||
end
|
||||
|
||||
# The full cycle of generation for whole project
|
||||
# @return [String] The complete change log
|
||||
def generate_log_for_all_tags
|
||||
|
||||
@@ -49,6 +49,42 @@ module GitHubChangelogGenerator
|
||||
string
|
||||
end
|
||||
|
||||
|
||||
# Main function to start change log generation
|
||||
#
|
||||
# @return [String] Generated change log file
|
||||
def compound_changelog
|
||||
log = "# Change Log\n\n"
|
||||
|
||||
if @options[:unreleased_only]
|
||||
log += generate_log_between_tags(all_tags[0], nil)
|
||||
elsif @options[:tag1] and @options[:tag2]
|
||||
tag1 = @options[:tag1]
|
||||
tag2 = @options[:tag2]
|
||||
tags_strings = []
|
||||
all_tags.each { |x| tags_strings.push(x["name"]) }
|
||||
|
||||
if tags_strings.include?(tag1)
|
||||
if tags_strings.include?(tag2)
|
||||
to_a = tags_strings.map.with_index.to_a
|
||||
hash = Hash[to_a]
|
||||
index1 = hash[tag1]
|
||||
index2 = hash[tag2]
|
||||
log += generate_log_between_tags(all_tags[index1], all_tags[index2])
|
||||
else
|
||||
fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
|
||||
end
|
||||
else
|
||||
fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
|
||||
end
|
||||
else
|
||||
log += generate_log_for_all_tags
|
||||
end
|
||||
|
||||
log += "\n\n\\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
||||
@log = log
|
||||
@log = log
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user