Class: Releasinator::Changelog::Updater
- Inherits:
-
Object
- Object
- Releasinator::Changelog::Updater
- Defined in:
- lib/changelog/updater.rb
Class Method Summary collapse
- .bump_version(version = GitUtil.tags.last) ⇒ Object
- .prompt_for_change_log(version, semver_type) ⇒ Object
Class Method Details
.bump_version(version = GitUtil.tags.last) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/changelog/updater.rb', line 11 def self.bump_version(version=GitUtil..last) loop do term = Printer.ask("What type of release is this? (major, minor, patch)") case term when "major", "minor", "patch" current_version = Semantic::Version.new(version).increment!(term.to_sym).to_s yield(current_version, term) return current_version else Printer.fail("release type must be one of: [major, minor, patch]") end end end |
.prompt_for_change_log(version, semver_type) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/changelog/updater.rb', line 27 def self.prompt_for_change_log(version, semver_type) new_changes = Dir.mktmpdir do |dir| tmp_cl = "#{dir}/tmp-changelog-release#{Time.now.to_i}.md" last_version = GitUtil..last tmp_change_log = "\n\n# Please enter a bulleted CHANGELOG list summarizing the changes for #{semver_type} version #{version}." tmp_change_log += "\n# Lines starting with '# ' will be ignored." tmp_change_log += "\n#" tmp_change_log += "\n# Changes since #{last_version}:" tmp_change_log += "\n#" tmp_change_log += "\n# " tmp_change_log += GitUtil.commits(from_tag=last_version).reverse.join("\n# ") tmp_change_log += "\n#" tmp_change_log += "\n" File.foreach("CHANGELOG.md") do |line| tmp_change_log += "# #{line}" end File.open(tmp_cl, "w") {|file| file.puts tmp_change_log } editor = ENV["EDITOR"] if editor == nil Printer.fail("Value of $EDITOR environment variable must be set in order to edit CHANGELOG") abort() elsif "" == CommandProcessor.command("which #{editor} | cat") Printer.fail("Value of $EDITOR (#{editor}) not found on path") abort() end system("$EDITOR #{tmp_cl}") new_changes = "" File.foreach(tmp_cl) do |line| if !line.start_with?("# ") && !line.start_with?("#\n") new_changes += line end end new_changes end self.update_changelog(new_changes, version) end |