From d52baa851480ca79d60333187cd0dab9338b7c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 30 Oct 2015 17:33:31 -0200 Subject: [PATCH] Add tasks to automatize CHANGELOG headers --- tasks/release.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tasks/release.rb b/tasks/release.rb index 2c7e927679..4711974b63 100644 --- a/tasks/release.rb +++ b/tasks/release.rb @@ -66,13 +66,24 @@ directory "pkg" end namespace :changelog do + task :header do + (FRAMEWORKS + ['guides']).each do |fw| + require 'date' + fname = File.join fw, 'CHANGELOG.md' + + header = "## Rails #{version} (#{Date.today.strftime('%B %d, %Y')}) ##\n\n* No changes.\n\n\n" + contents = header + File.read(fname) + File.open(fname, 'wb') { |f| f.write contents } + end + end + task :release_date do (FRAMEWORKS + ['guides']).each do |fw| require 'date' - replace = '\1(' + Date.today.strftime('%B %d, %Y') + ')' + replace = "## Rails #{version} (#{Date.today.strftime('%B %d, %Y')}) ##\n" fname = File.join fw, 'CHANGELOG.md' - contents = File.read(fname).sub(/^([^(]*)\(unreleased\)/, replace) + contents = File.read(fname).sub(/^(## Rails .*)\n/, replace) File.open(fname, 'wb') { |f| f.write contents } end end