class Verto::DSL::UpdateChangelog

Constants

InvalidChangelogSource
SOURCES

Public Instance Methods

call(new_version:, confirmation: true, filename: 'CHANGELOG.md', with: :merged_pull_requests_with_bracketed_labels) click to toggle source
# File lib/verto/dsl/update_changelog.rb, line 22
def call(new_version:, confirmation: true, filename: 'CHANGELOG.md', with: :merged_pull_requests_with_bracketed_labels)
  verify_file_presence!(filename)

  stdout.puts separator
  changelog_changes = format_changes(new_version, version_changes(with))

  exit if confirmation && !cli_helpers.confirm("Create new Release?\n" \
                                               "#{separator}\n" \
                                               "#{changelog_changes}" \
                                               "#{separator}\n")
  update_file(filename, changelog_changes)
end

Private Instance Methods

format_changes(new_version, version_changes) click to toggle source
# File lib/verto/dsl/update_changelog.rb, line 51
def format_changes(new_version, version_changes)
  Mustache.render(changelog_format, { new_version: new_version, version_changes: version_changes }) + "\n"
end
separator() click to toggle source
# File lib/verto/dsl/update_changelog.rb, line 55
def separator
  '---------------------------'
end
update_file(filename, changelog_changes) click to toggle source
# File lib/verto/dsl/update_changelog.rb, line 47
def update_file(filename, changelog_changes)
  DSL::File.new(filename).prepend(changelog_changes)
end
verify_file_presence!(filename) click to toggle source
# File lib/verto/dsl/update_changelog.rb, line 37
def verify_file_presence!(filename)
  return if Verto.project_path.join(filename).exist?

  raise Verto::ExitError, "changelog file '#{filename}' doesnt exist"
end
version_changes(with) click to toggle source
# File lib/verto/dsl/update_changelog.rb, line 43
def version_changes(with)
  SOURCES[with].call(executor)
end