def self.tag_version(v, release_notes = false)
if dirty_tree?
puts "You have uncommitted files. Refusing to tag a dirty tree."
else
if release_notes
prev_tag = `git describe --always`.strip.gsub(/-\d+-g[0-9a-f]+$/, '')
log_file = Tempfile.new('gvb')
log_file.puts "\n\n\n# Write your release notes above. The first line should be the release name.\n# To help you remember what's in here, the commits since your last release\n# are listed below. This will become v\#{v}\n#\n".gsub(/^\t\t\t\t\t/, '')
log_file.close
system("git log --no-show-signature --format='# %h %s' #{prev_tag}..HEAD >>#{log_file.path}")
pre_hash = Digest::SHA1.hexdigest(File.read(log_file.path))
system("git config -e -f #{log_file.path}")
if Digest::SHA1.hexdigest(File.read(log_file.path)) == pre_hash
puts "Release notes not edited; aborting"
log_file.unlink
return
end
puts "Tagging version #{v}..."
system("git tag -a -F #{log_file.path} v#{v}")
log_file.unlink
else
system("git tag -a -m 'Version v#{v}' v#{v}")
end
system("git push > #{DEVNULL} 2>&1")
system("git push --tags > #{DEVNULL} 2>&1")
end
end