Created
April 16, 2012 17:56
-
-
Save obale/2400349 to your computer and use it in GitHub Desktop.
rake changelog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "grit" | |
# This ChangeLog code works if you work on a 'develop' branch and if you merge only | |
# with the 'master' branch if you release a version. Each release (merge) should | |
# include also a creation of a tag. | |
# | |
# Sponsored by Sigimera (http://www.sigimera.org) | |
desc "Outputs the ChangeLog of the current release" | |
task :changelog do | |
repo = Grit::Repo.new('.') | |
currentMerge = repo.log('origin/master', nil, :merges => true)[0].id | |
lastMerge = repo.log('origin/master', nil, :merges => true)[1].id | |
changes = repo.commits_between(lastMerge, currentMerge) | |
tags = repo.tags | |
if !changes.nil? | |
changes.reverse! | |
tags.each do |tag| | |
if tag.commit.sha.eql?(changes[0].id) | |
puts "=> Current version: \033[0;31m#{tag.name}\033[0m (tagged)" | |
end | |
end | |
changes.each do |commit| | |
puts "\033[0;33m#{commit.id[0,7]}\033[0m - #{commit.date} - \033[0;32m#{commit.message}\033[0m" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment