class Changelog::Bundler
Public Class Methods
new(version, changelog_file, include_date = false, no_commit = false, dry_run = false, force = false)
click to toggle source
# File lib/changelog/bundler.rb, line 11 def initialize(version, changelog_file, include_date = false, no_commit = false, dry_run = false, force = false) @version = version @changelog_file = changelog_file || 'CHANGELOG.md' @include_date = include_date @unreleased_entries = nil @no_commit = no_commit @dry_run = dry_run @force = force end
Public Instance Methods
execute()
click to toggle source
# File lib/changelog/bundler.rb, line 21 def execute assert_entries! update_changelog delete_file_entries commit_changes unless @no_commit || @dry_run end
Private Instance Methods
assert_entries!()
click to toggle source
# File lib/changelog/bundler.rb, line 80 def assert_entries! return if unreleased_entries.length > 0 return if @force fail_with "No entries in '#{unreleased_path}' available! Use `--force` to write an empty version." end
commit_changes()
click to toggle source
# File lib/changelog/bundler.rb, line 41 def commit_changes success = Kernel.system("git add #{@changelog_file} #{unreleased_path}") success &&= Kernel.system("git commit -m \"🧾 Update #{@changelog_file} for v#{@version.to_patch}\n\n[ci skip]\"") fail_with "Files could not be commited" unless success end
delete_file_entries()
click to toggle source
# File lib/changelog/bundler.rb, line 68 def delete_file_entries unreleased_paths.each do |path| if @dry_run $stdout.puts "#{'delete'.red} #{path}" next end File.delete(path) if File.exist?(path) end end
unreleased_entries()
click to toggle source
# File lib/changelog/bundler.rb, line 48 def unreleased_entries return @unreleased_entries if @unreleased_entries @unreleased_entries = [] unreleased_paths.each do |fname| @unreleased_entries << Entry.from_yml(fname) end @unreleased_entries end
unreleased_path()
click to toggle source
# File lib/changelog/bundler.rb, line 60 def unreleased_path File.join('changelogs', 'unreleased') end
unreleased_paths()
click to toggle source
# File lib/changelog/bundler.rb, line 64 def unreleased_paths Dir.glob(File.join(unreleased_path, '*.yml')) end
update_changelog()
click to toggle source
# File lib/changelog/bundler.rb, line 33 def update_changelog markdown = Changelog::MarkdownGenerator.new(@version, unreleased_entries, include_date: @include_date).to_s updater = Updater.new(@changelog_file, @dry_run) updater.insert(@version, markdown) end