#!/usr/bin/ruby
# -*- mode: ruby; coding: utf-8-unix; indent-tabs-mode: nil -*-
#
# Copyright(C) Youhei SASAKI All rights reserved.
# $Lastupdate: 2011/09/16 16:59:47$
#
# Author: Youhei SASAKI <uwabami@gfd-dennou.org>
# License:
# This program is permitted under the principle of "NO WARRANTY" and
# "NO RESPONSIBILITY". The author shall not be liable for any event
# arising in any way out of the use of these resources.
#
# Redistribution in source and binary forms, with or without
# modification, is also permitted provided that the above copyright
# notice, disclaimer and this condition are retained.
#
# Code:
repogroup = 'hoge'

REPOS=ARGV[0]
REV=ARGV[1].to_i

svnlookbin="/usr/bin/env LANG=ja_JP.eucjp /usr/bin/svnlook"

svnauthor=%x{ #{svnlookbin} author #{REPOS} -r #{REV}}.chomp!
svndate=%x{ /usr/bin/env LANG=C /usr/bin/svnlook date #{REPOS} -r #{REV}}.chomp!
svnchanged=%x{ #{svnlookbin} changed #{REPOS} -r #{REV}}.chomp!
svnlog=%x{ #{svnlookbin} log #{REPOS} -r #{REV}}.chomp!
svndiff=%x{ #{svnlookbin} diff #{REPOS} -r #{REV}}.chomp!


toaddr = repogroup + "@gfd-dennou.org"
fromaddr = svnauthor + "@dennou-k.gfd-dennou.org"

require 'net/smtp'
require 'kconv'

Net::SMTP.start( 'localhost', 25 ) {|smtp|
  smtp.send_mail <<EOF, fromaddr, *toaddr
From: #{fromaddr}
To: #{toaddr};
Subject: #{repogroup} commit
Date: #{svndate}
Content-Type: text/plain; charset = ISO-2022-JP

#{svndate.tojis}, user #{svnauthor} committed following file(s)

Log Message:
#{svnlog.tojis}

Modified Files:
#{svnchanged.tojis}

EOF
}
