Skip to content

Commit

Permalink
Revert caching and duplicate checking
Browse files Browse the repository at this point in the history
  • Loading branch information
wbclark committed Sep 7, 2023
1 parent 6421212 commit 2ab44bb
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions lib/tool_belt/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module ToolBelt
class Changelog

attr_accessor :issues, :bugs, :features, :release_environment, :config, :cached_changelog_content
attr_accessor :issues, :bugs, :features, :release_environment, :config

def initialize(config, release_environment, issues)
self.config = config
Expand All @@ -13,26 +13,15 @@ def initialize(config, release_environment, issues)
self.issues = issues
self.release_environment = release_environment

cache_existing_changelog
generate_entries(@issues)
changelog = format_entries
releases = config.releases.keys.map { |key| key.to_s }
minor_release = releases.sort_by { |v| v.split('.').map(&:to_i) }.last
write_changelog(changelog, minor_release, release_environment.main_repo, config.code_name)
end

def cache_existing_changelog
filepath = File.join(release_environment.repo_location(config.project), 'CHANGELOG.md')
@cached_changelog_content = File.exist?(filepath) ? File.read(filepath) : ''
end

def issue_already_in_changelog?(issue)
@cached_changelog_content.include?(issue.html_url)
end

def generate_entries(issues)
issues.select(&:closed?).each do |issue|
next if issue_already_in_changelog?(issue)
generate_entry(issue)
end
end
Expand Down Expand Up @@ -131,7 +120,7 @@ def write_changelog(changelog, release, repo, code_name = '')
else
file.puts("# #{release} (#{Date.today.to_s})")
end
file.write(changelog + '\n\n' + @cached_changelog_content)
file.write(changelog + @cached_changelog_content)

if File.exist?('CHANGELOG.md.backup')
File.open('CHANGELOG.md.backup', 'r') { |backup| file.write(backup.read) }
Expand Down

0 comments on commit 2ab44bb

Please sign in to comment.