class Object
Public Instance Methods
assert_tag_exists(version)
click to toggle source
# File lib/rake-extensions.rb, line 198 def assert_tag_exists(version) raise "tag #{version} missing" if `git tag -l #{version}`.length == 0 end
create_changelog(current_version, next_version)
click to toggle source
# File lib/rake-extensions.rb, line 201 def create_changelog(current_version, next_version) sha1s = `git log #{current_version}..HEAD --oneline`.strip.split(/\n/).collect { |line| line.split(' ').first } log_entries = [] sha1s.each do |sha1| raw_log = `git log --format=%B -n 1 #{sha1}`.strip log_lines = raw_log.split(/\n/) first_line = true entry = log_lines .reject{|x| x.strip == ""} .collect do |line| if line =~ /^\s*\*/ "#{line.sub(/\s*\*/, " *")}" else res = first_line ? "* #{line}" : " #{line}" first_line = false res end end log_entries << entry end log = log_entries.join("\n") date = Time.now.strftime("%m/%d/%Y") log_entry = "### [#{next_version}] - #{date}\n#{log}" puts "logmessages:\n#{log}" ['CHANGELOG.md'].each do |file| if !File.exist?(file) File.open(file, 'w') {|f| f.write("# Changelog") } end text = File.read(file) new_contents = text.gsub(/^#\sChangelog/, "# Changelog\n\n#{log_entry}") File.open(file, "w") { |f| f.puts new_contents } end end
current_version_with_regex(filelist, r)
click to toggle source
# File lib/rake-extensions.rb, line 70 def current_version_with_regex(filelist, r) current_version = nil FileUtils.cd @version_dir, :verbose => false do filelist.each do |file| text = File.read(file) if match = text.match(r) current_version = match.captures[1] end end end current_version end