Skip to content

Instantly share code, notes, and snippets.

@tjhanley
Created November 5, 2011 21:47
Show Gist options
  • Save tjhanley/1342064 to your computer and use it in GitHub Desktop.
Save tjhanley/1342064 to your computer and use it in GitHub Desktop.
Capistrano task for creating a change log file
desc "Create about and revision files."
task :rev_deployment, :roles => [:app, :web] do
require 'grit'
require 'chronic'
# include Grit
work_dir = File.join(File.dirname(__FILE__), '../../')
g = Grit::Repo.new(work_dir)
since = Chronic.parse('last week friday')
msg = "\n"
rev_file = File.join(File.dirname(__FILE__), '../../','tmp/revision.txt')
File.new(rev_file,"w+") unless File.exists?(rev_file)
File.open(rev_file,"w") do |f|
f.puts "Version Info"
f.puts "================================================="
f.puts "Version: #{real_revision}"
f.puts "Deploy Date: #{Time.now}"
f.puts "Branch: #{exists?(:branch) ? branch : 'local'}"
if ENV != 'production'
f.puts "Changes: Last #{since}"
f.puts "================================================="
g.commits_since(branch,since).each do |commit|
# commit = g.gcommit(c)
f.puts "[#{commit.committed_date.strftime("%m-%d-%y %I:%M%p")}] #{commit.committer} - #{commit.committer.email}"
f.puts "#{commit.message}"
f.puts ""
end
end
end
upload(rev_file,"#{release_path}/public/revision.txt")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment