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, Util::VERSION_FILE
Instance Method Summary collapse
-
#initialize(version, previous:) ⇒ Release
constructor
A new instance of Release.
- #prepare(edit: false) ⇒ Object
Methods included from Util
#guarded_system, #remove_stored_version, #stored_version
Constructor Details
#initialize(version, previous:) ⇒ Release
Returns a new instance of Release.
7 8 9 10 11 12 13 14 |
# File 'lib/releasetool/release.rb', line 7 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
16 17 18 19 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 |
# File 'lib/releasetool/release.rb', line 16 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.exists?(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}" if edit system("open #{notes_file}") end end if File.exists?(VERSION_FILE) from_version = @previous.to_s_without_v to_version = @version.to_s_without_v guarded_system("cat #{VERSION_FILE} | sed s/#{from_version}/#{to_version.gsub('.', '\.')}/ > #{VERSION_FILE}.tmp") guarded_system("mv #{VERSION_FILE}.tmp #{VERSION_FILE}") end end |