Auto detect since tag from base file

This commit is contained in:
Raphaël Pinson 2015-08-05 10:43:17 +02:00
parent 4202b95076
commit bfae7b9a45

View File

@ -52,6 +52,14 @@ module GitHubChangelogGenerator
[newer_tag_link, newer_tag_name, newer_tag_time] [newer_tag_link, newer_tag_name, newer_tag_time]
end end
def detect_since_tag
if File.file?(@options[:base])
reader = GitHubChangelogGenerator::Reader.new
content = reader.read(@options[:base])
return content[0]["version"] if content
end
end
# Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags # Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags
# #
# @return [Array] # @return [Array]
@ -64,6 +72,7 @@ module GitHubChangelogGenerator
def filter_since_tag(all_tags) def filter_since_tag(all_tags)
filtered_tags = all_tags filtered_tags = all_tags
tag = @options[:since_tag] tag = @options[:since_tag]
tag ||= detect_since_tag
if tag if tag
if all_tags.map(&:name).include? tag if all_tags.map(&:name).include? tag
idx = all_tags.index { |t| t.name == tag } idx = all_tags.index { |t| t.name == tag }