Skip to content

Instantly share code, notes, and snippets.

@y-yagi
Last active August 29, 2015 14:00
Show Gist options
  • Save y-yagi/11356420 to your computer and use it in GitHub Desktop.
Save y-yagi/11356420 to your computer and use it in GitHub Desktop.
rails commit log 確認用
#!/usr/bin/env ruby
require 'git'
require 'time'
WORKING_DIR = '/home/yaginuma/program/rails/rails'
BLOG_DIR = '/home/yaginuma/Dropbox/blog/rails-commit-log/'
HEADER = <<EOS
rails commit log流し読み(%s)
%s分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
or
CHANGELOGへの追加はありませんでした。
EOS
FORMAT = <<-EOS
***
[%s](https://github.com/rails/rails/commit/%s)
https://github.com/rails/rails/commit/%s
EOS
g = Git.open(WORKING_DIR)
today = Date.today
g.pull
logs = g.log(300).since('2 days ago')
type = (ARGV != 0 && ARGV[0] == 'test') ? :test : :normal
result, header = '', ''
logs.reverse_each do |f|
next if type != :test && !(((today - 1)...today).include? f.date.to_date)
result << FORMAT % [f.message.split("\n").first, f.sha, f.sha]
result << "#{f.date.to_s}\n"
end
if type == :normal
file_name = Date.today.to_time.strftime("%Y%m%d")
header_date = (Date.today - 1).to_time.strftime("%Y/%m/%d")
header = HEADER % [header_date, header_date]
else
file_name = 'test'
end
open(BLOG_DIR + file_name + '.log', 'w') do |f|
f.write(header)
f.write(result)
end
p "finish!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment