Created
July 22, 2011 07:14
-
-
Save naoto/1099017 to your computer and use it in GitHub Desktop.
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
# -*- encoding: utf-8 -*- | |
require 'yaml' | |
require 'net/smtp' | |
def svnlook(command, repos, rev) | |
`svnlook #{command} "#{repos}" -r #{rev}`.chomp.encode("EUC-JP") | |
end | |
begin | |
repos = ARGV[0] | |
rev = ARGV[1] | |
author = svnlook('author', repos, rev) | |
message = svnlook('log', repos, rev) | |
files = svnlook('changed', repos, rev) | |
project = File.basename(repos) | |
conf = YAML::load_file('commit_mail.yaml')[project] | |
if conf | |
smtp_addr = conf['smtp'] | |
smtp_port = conf['port'] | |
mail_from = conf['from'] | |
mail_to = conf['to'] | |
messg= <<EOF | |
From: #{mail_from} | |
To: #{mail_to.join(',')} | |
Subject: [svn:#{project}:#{rev}] commit by #{author.gsub("@example.CO.JP",'')} | |
repository: #{project} | |
revision: #{rev} | |
author: #{author.gsub("@example.CO.JP",'')} | |
---------------- | |
message: | |
#{message} | |
---------------- | |
changed: | |
#{files} | |
EOF | |
Net::SMTP.start(smtp_addr, smtp_port) do |smtp| | |
smtp.send_mail messg.force_encoding("iso-2022-jp").force_encoding("ASCII-8BIT"), mail_from, mail_to | |
end | |
end | |
rescue => e | |
puts e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment