Class: SemanticRelease::Updaters::Changelog

Inherits:
BaseUpdater
  • Object
show all
Defined in:
lib/semantic_release/updaters/changelog.rb

Constant Summary collapse

FILES =
%w[CHANGELOG.md history.rdoc].freeze

Class Method Summary collapse

Methods inherited from BaseUpdater

current_version, current_version_tag, gemspec_present?, semver_file

Class Method Details

.prepend_version(filepath) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/semantic_release/updaters/changelog.rb', line 17

def self.prepend_version(filepath)
  heading_marker = filepath.end_with?(".rdoc") ? "==" : "##"
  content = File.read(filepath)
  File.open(filepath, "w") do |f|
    f.puts("#{heading_marker} #{current_version_tag} (#{Time.now.strftime("%d %B %Y")})\n\n")
    f.print(content)
  end
end

.updateObject



8
9
10
11
12
13
14
15
# File 'lib/semantic_release/updaters/changelog.rb', line 8

def self.update
  FILES.each do |file|
    next unless File.exist?(file)

    prepend_version(file)
    `git add #{file}`
  end
end