Class: Verto::DSL::UpdateChangelog

Inherits:
Object
  • Object
show all
Defined in:
lib/verto/dsl/update_changelog.rb,
lib/verto/dsl/update_changelog/filtered_by.rb,
lib/verto/dsl/update_changelog/with_commit_messages.rb,
lib/verto/dsl/update_changelog/with_merged_pull_requests.rb

Defined Under Namespace

Modules: FilteredBy Classes: WithCommitMessages, WithMergedPullRequests

Constant Summary collapse

InvalidChangelogSource =
Class.new(Verto::ExitError)
BRACKETED_LABELS_REGEXP =
/^[[:space:]]*\[.*\]/.freeze
SOURCES =
StrictHash.new(
  {
    merged_pull_requests_with_bracketed_labels: WithMergedPullRequests.filtered_by(BRACKETED_LABELS_REGEXP),
    commits_with_bracketed_labels: WithCommitMessages.filtered_by(BRACKETED_LABELS_REGEXP),
    merged_pull_requests_messages: WithMergedPullRequests,
    commit_messages: WithCommitMessages
  },
  default_proc: ->(hash, _) { raise InvalidChangelogSource, "Invalid CHANGELOG Source, avaliable options: '#{hash.keys.join(',')}'" }
)

Instance Method Summary collapse

Instance Method Details

#call(new_version:, confirmation: true, filename: 'CHANGELOG.md', with: :merged_pull_requests_with_bracketed_labels, message_pattern: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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, message_pattern: nil)
  verify_file_presence!(filename)

  changelog_changes = format_changes(new_version, version_changes(with, message_pattern))

  if confirmation
    stdout.puts separator
    stdout.puts changelog_changes
    stdout.puts separator
    changelog_changes = select_changelog_text(changelog_changes)
  end

  update_file(filename, changelog_changes)
end