Class: Releasetool::Release
- Inherits:
-
Object
- Object
- Releasetool::Release
- Includes:
- Util
- Defined in:
- lib/releasetool/release.rb
Constant Summary
Constants included from Util
Util::DIR, Util::RELEASE_MARKER_FILE, Util::TEMPLATE_FILE
Instance Method Summary collapse
-
#initialize(version, previous:) ⇒ Release
constructor
A new instance of Release.
- #prepare(edit: false) ⇒ Object
Methods included from Util
#config, #guarded_capture, #guarded_system, #remove_stored_version, #stored_version, version_file
Constructor Details
#initialize(version, previous:) ⇒ Release
Returns a new instance of Release.
10 11 12 13 14 15 16 17 18 |
# File 'lib/releasetool/release.rb', line 10 def initialize(version, previous:) raise "Version must be a Releasetool::Version" unless version.is_a?(Releasetool::Version) if previous raise "Previous must be nil or a Releasetool::Version" unless version.is_a?(Releasetool::Version) end @version = version @previous = previous end |
Instance Method Details
#prepare(edit: false) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/releasetool/release.rb', line 20 def prepare(edit: false) puts headers commits = `git log #{@previous}..HEAD --pretty=format:"- %B"` notes = commits.gsub("\n\n", "\n") notes_file = "#{DIR}/#{@version}.md" if File.exist?(notes_file) puts "-" * 80 puts " File '#{notes_file}' already exists (appending)" puts "-" * 80 File.open(notes_file, 'a') do |f| f.puts("\n\nAPPENDED:\n\n") f.puts(notes) end else ensure_dir File.open(notes_file, 'w') do |f| f.puts(headers) f.puts(notes) end puts "written to #{notes_file}" system("open #{notes_file}") if edit end return unless File.exist?(Releasetool::Util.version_file) from_version = @previous.to_s_without_v to_version = @version.to_s_without_v guarded_system("cat #{Releasetool::Util.version_file} | sed s/#{from_version}/#{to_version.gsub('.', '\.')}/ > #{Releasetool::Util.version_file}.tmp") guarded_system("mv #{Releasetool::Util.version_file}.tmp #{Releasetool::Util.version_file}") end |