5 original_argv = ARGV.dup
8 found_include_option = false
9 while (arg = original_argv.shift)
10 if found_include_option
11 $LOAD_PATH.unshift(arg)
12 found_include_option = false
15 when "-I", "--include"
16 found_include_option = true
17 when /\A-I/, /\A--include=?/
19 $LOAD_PATH.unshift(path) unless path.empty?
26 def extract_email_address(address)
27 if /<(.+?)>/ =~ address
34 def sendmail(to, from, mail, server=nil, port=nil)
35 server ||= "localhost"
36 from = extract_email_address(from)
37 to = to.collect {|address| extract_email_address(address)}
38 Net::SMTP.start(server, port) do |smtp|
39 smtp.open_message_stream(from, to) do |f|
46 require 'svn/commit-mailer'
47 Svn::CommitMailer.run(argv)
48 rescue Exception => error
54 from = "#{ENV['USER']}@#{Socket.gethostname}"
61 raise OptionParser::ParseError
63 _, _, _to, options = Svn::CommitMailer.parse(argv)
65 to = options.error_to unless options.error_to.empty?
66 from = options.from || from
67 subject = "#{options.name}: #{subject}" if options.name
68 server = options.server
70 rescue OptionParser::MissingArgument
71 argv.delete_if {|arg| $!.args.include?(arg)}
73 rescue OptionParser::ParseError
75 _, _, _to, *_ = ARGV.reject {|arg| /^-/.match(arg)}
81 #{error.class}: #{error.message}
82 #{error.backtrace.join("\n")}
88 sendmail(to, from, <<-MAIL, server, port)
90 Content-Type: text/plain; charset=us-ascii
91 Content-Transfer-Encoding: 7bit
95 Date: #{Time.now.rfc2822}