您好,登錄后才能下訂單哦!
#!/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 =<<EOF ------------------- ./script.rb svn_path ------------------- EOF if dir.nil? puts usage Process.exit(1) end if not(File.directory?(dir)) puts "It's Not exist Dir" Process.exit(2) end Dir::chdir(dir) if not(File.directory?'.svn') puts "This Dir is not SVN Working Dir" Process.exit(3) end `svn log -v>/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 = <<EOF //////////////////////////////////////////////////////////////////////// Module:#{re_module} Release-#{re_no} //////////////////////////////////////////////////////////////////////// EOF return release_no end def tag(dir,log,project) copy_www = $svn_ser + "/" + project + dir.split(project)[-1] #$svn_ser + / + TD1T + /Code/RTL tag_www = $svn_ser + "/" + project + "/Tag" + dir.split(project)[-1] #$svn_ser + / + TD1T + /Tag + /Code/RTL if File.exist?("release_notes.txt") #exist dir_no = check_re_no + 1 log = rel_title(dir_no.to_s) + "\n\n" +log writefile(log) `svn ci release_notes.txt -m "Release-"#{dir_no.to_s}` `svn copy #{copy_www} #{tag_www + "/release-" + dir_no.to_s } -m "Release-"#{dir_no.to_s}` return dir_no else log = rel_title('1.0') + "\n\n" +log writefile(log) `svn ci release_notes.txt -m "Release-1.0"` `cd #{dir.split(project)[0] + project} && svn mkdir --parents #{"./Tag" + dir.split(project)[1]} && svn ci #{dir.split(project)[0] + project + "/Tag"} -m "add tag path"` `svn copy #{copy_www} #{tag_www + "/release-1.0"} -m "Release-1.0"` return "1.0" end end def mailer(mailadd,re_no,svn_name) re_no = "Release:% 31s" %re_no re_module = "Module:% 33s" % Dir.pwd.split('/')[-1] re_user = "Author:% 34s" % `cd $HOME && grep username -h -A2 ./.subversion/auth/svn.simple/* | tail -1` project = "Project:% 33s" % svn_name path = "Path:% 36s" % Dir.pwd.split(svn_name)[1] File.open(mailadd,'r').each {|dst| msgstr = <<END_OF_MESSAGE From: SVN <sync.svn@163.com> 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`
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。