From 0fae7e0f9e4700971a7a5e0890f2153158c0a5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 25 Aug 2015 13:45:13 +0200 Subject: [PATCH] Use since_tag as default for older_tag --- .../generator/generator_generation.rb | 2 +- .../generator/generator_tags.rb | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/github_changelog_generator/generator/generator_generation.rb b/lib/github_changelog_generator/generator/generator_generation.rb index 1cd0349..41fd1f3 100644 --- a/lib/github_changelog_generator/generator/generator_generation.rb +++ b/lib/github_changelog_generator/generator/generator_generation.rb @@ -103,7 +103,7 @@ module GitHubChangelogGenerator def generate_log_between_tags(older_tag, newer_tag) filtered_issues, filtered_pull_requests = filter_issues_for_tags(newer_tag, older_tag) - older_tag_name = older_tag.nil? ? nil : older_tag["name"] + older_tag_name = older_tag.nil? ? detect_since_tag : older_tag["name"] if newer_tag.nil? && filtered_issues.empty? && filtered_pull_requests.empty? # do not generate empty unreleased section diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index 2cc28c8..db2579c 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -54,11 +54,13 @@ module GitHubChangelogGenerator # @return [Object] try to find newest tag using #Reader and :base option if specified otherwise returns nil def detect_since_tag - if @options[:base] && File.file?(@options[:base]) + @since_tag ||= @options[:since_tag] + if @since_tag.nil? && @options[:base] && File.file?(@options[:base]) reader = GitHubChangelogGenerator::Reader.new content = reader.read(@options[:base]) - return content[0]["version"] if content + @since_tag = content[0]["version"] if content end + @since_tag end # Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags @@ -74,8 +76,7 @@ module GitHubChangelogGenerator # @return [Array] filtered tags according :since_tag option def filter_since_tag(all_tags) filtered_tags = all_tags - tag = @options[:since_tag] - tag ||= detect_since_tag + tag = detect_since_tag if tag if all_tags.map(&:name).include? tag idx = all_tags.index { |t| t.name == tag }