#!/usr/bin/ruby
require 'fileutils'
require 'net/smtp'
dir = ARGV[0]
to_mail = "" #mail address list
$svn_ser = "http://192.168.12.12/svn"
if to_mail.empty?
puts "Please Setting Maillist"
Process.exit(7)
end
`export SVN_EDITOR="/bin/vi"`
usage =</tmp/svn_temp_temp`
svn_log = File.open("/tmp/svn_temp_temp",'r')
def format_srt(sa)
m = 0
str, ok = "", ""
sa.each {|x|
if not(/^---+$/.match(x).nil?)
if /^Commit:Release-\d+\.\d+/.match(str) and m == 1
break
else ok = ok + str
end
str = x
m = 1
elsif not(/^r[0-9]+\s/.match(x).nil?)
tmp_array = x.split('|')
str = str + "\nReVersion:%42s\nAuthor:%45s\nDate:%47s\n" %[tmp_array[0].chop,tmp_array[1][1,18].chop,tmp_array[2][1,19]]
elsif not(/^\s..[ADUCMG]|^Changed\spaths/.match(x).nil?)
if /\/tag\/release-\d+\.|release_notes\.txt/.match(x).nil?
str = str + x
else
x = ''
end
elsif not(/\s.+\w.*|\w.*/.match(x).nil?)
str = str + "Commit:" + x
elsif not(/\s.*$/.match(x).nil?)
str = str
end
}
return ok.gsub(/\s*$/,'').gsub(/Changed paths/,'ChangePath') + "\n------------------------------------------------------------------------"
end
def check_re_no()
re_no = ""
File.open("release_notes.txt",'r').each{ |x|
if /Release-/.match(x)
re_no = x
break
end
}
return re_no.split('-')[1].to_f
end
def rel_title(re_no)
re_module = Dir.pwd.split('/')[-1]
release_no = <
To: #{dst.chomp}
Subject: SVN_Release
#{project.chomp}
#{re_no.chomp}
#{re_module.chomp}
#{re_user.chomp}
#{path}
END_OF_MESSAGE
acct = 'svn@163.com'
domain = "163.com"
pass = '1q1123452'
Net::SMTP.start('smtp.163.com', 25, domain, acct, pass, :login) { |smtp|
smtp.send_message msgstr,'svn@163.com',dst.chomp
}
#Net::SMTP.start(server, port, domain, acct, passwd, authtype)
}
end
def writefile(str)
aFile = File.new("release_notes.txt","w")
aFile.puts str
aFile.close
end
def svn_project_name()
name = ''
File.open(Dir.pwd + "/.svn/all-wcprops",'r').each { |x|
if /!svn\/ver\/\d+/.match(x)
name = x
break
end
}
return name.split('/')[2]
end
svn_name = svn_project_name
re_no = tag(Dir.pwd,format_srt(svn_log),svn_name)
mailer(to_mail,re_no,svn_name)
puts "Release-#{re_no} Success"
`rm -f /tmp/svn_temp_temp`
当前文章:ruby_svntag及发邮件
文章转载:
http://cdxtjz.cn/article/phoogd.html