SOURCES: cvsspam-svnspam-branch.diff - svn_cvsspam.rb updated from cvsspam....
glen
glen at pld-linux.org
Wed Mar 4 23:04:28 CET 2009
Author: glen Date: Wed Mar 4 22:04:28 2009 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- svn_cvsspam.rb updated from cvsspam.rb (merged 230:258)
---- Files affected:
SOURCES:
cvsspam-svnspam-branch.diff (1.2 -> 1.3)
---- Diffs:
================================================================
Index: SOURCES/cvsspam-svnspam-branch.diff
diff -u SOURCES/cvsspam-svnspam-branch.diff:1.2 SOURCES/cvsspam-svnspam-branch.diff:1.3
--- SOURCES/cvsspam-svnspam-branch.diff:1.2 Wed Mar 4 21:10:32 2009
+++ SOURCES/cvsspam-svnspam-branch.diff Wed Mar 4 23:04:23 2009
@@ -1,14 +1,68 @@
--- cvsspam-0.2.12/svn_cvsspam.rb 2005-07-11 18:53:29.000000000 +0300
-+++ cvsspam-svn/svn_cvsspam.rb 2008-08-07 17:27:52.632725455 +0300
-@@ -18,7 +18,7 @@
++++ cvsspam-svn/svn_cvsspam.rb 2009-03-04 23:47:04.364552847 +0200
+@@ -18,8 +18,9 @@
# to your cvssppam.conf
-$version = "0.2.11"
+$version = "0.2.12"
++require 'time'
$maxSubjectLength = 200
+ $maxLinesPerDiff = 1000
+@@ -35,10 +36,6 @@
+ a<b ? a : b
+ end
+
+-# NB must ensure the time is UTC
+-# (the Ruby Time object's strftime() doesn't supply a numeric timezone)
+-DATE_HEADER_FORMAT = "%a, %d %b %Y %H:%M:%S +0000"
+-
+ # Perform (possibly) multiple global substitutions on a string.
+ # the regexps given as keys must not use capturing subexpressions '(...)'
+ class MultiSub
+@@ -48,7 +45,7 @@
+ @mash = Array.new
+ expr = nil
+ hash.each do |key,val|
+- if expr == nil ; expr="(" else expr<<"|(" end
++ if expr == nil ; expr="(" else expr << "|(" end
+ expr << key << ")"
+ @mash << val
+ end
+@@ -116,6 +113,8 @@
+ UNDERSCORE = chr("_")
+ SPACE = chr(" ")
+ TAB = chr("\t")
++ HOOK = chr("?")
++ EQUALS = chr("=")
+
+ # encode a header value according to the RFC-2047 quoted-printable spec,
+ # allowing non-ASCII characters to appear in header values, and wrapping
+@@ -137,8 +136,8 @@
+ # return a string representing the given character-code in quoted-printable
+ # format
+ def quoted_encode_char(b)
+- if b>126 || b==UNDERSCORE || b==TAB
+- sprintf("=%02x", b)
++ if b>126 || b==UNDERSCORE || b==TAB || b==HOOK || b==EQUALS
++ sprintf("=%02X", b)
+ elsif b == SPACE
+ "_"
+ else
+@@ -163,8 +162,9 @@
+
+ # gives a string starting "=?", and including a charset specification, that
+ # marks the start of a quoted-printable character sequence
+- def marker_start_quoted
+- "=?#{@charset}?#{@encoding}?"
++ def marker_start_quoted(charset=nil)
++ charset = @charset if charset.nil?
++ "=?#{charset}?#{@encoding}?"
+ end
+
+ # test to see of the given string contains non-ASCII characters
@@ -339,8 +339,11 @@
# gets the Repository object for the first component of the given path
@@ -102,15 +156,31 @@
bugzillaSub = proc { |match|
match =~ /([0-9]+)/
"<a href=\"#{$bugzillaURL.sub(/%s/, $1)}\">#{match}</a>"
-@@ -541,9 +564,15 @@
+@@ -541,9 +564,31 @@
match =~ /([0-9]+)/
"<a href=\"#{$ticketURL.sub(/%s/, $1)}\">#{match}</a>"
}
++issueSub = proc { |match|
++ match =~ /([0-9]+)/
++ "<a href=\"#{$issueURL.sub(/%s/, $1)}\">#{match}</a>"
++}
+wikiSub = proc { |match|
-+ match =~ /\[\[(.*)\]\]/
++ match =~ /\[\[(.*?)\]\]/
+ raw = $1
+ "<a href=\"#{$wikiURL.sub(/%s/, urlEncode(raw))}\">[[#{raw}]]</a>"
+}
++xplannerIterationSub = proc { |match|
++ match =~ /([0-9]+)/
++ "<a href=\"#{$xplannerIterationURL.sub(/%s/, $1)}\">#{match}</a>"
++}
++xplannerProjectSub = proc { |match|
++ match =~ /([0-9]+)/
++ "<a href=\"#{$xplannerProjectURL.sub(/%s/, $1)}\">#{match}</a>"
++}
++xplannerStorySub = proc { |match|
++ match =~ /([0-9]+)/
++ "<a href=\"#{$xplannerStoryURL.sub(/%s/, $1)}\">#{match}</a>"
++}
commentSubstitutions = {
'(?:mailto:)?[\w\.\-\+\=]+\@[\w\-]+(?:\.[\w\-]+)+\b' => mailSub,
- '\b(?:http|https|ftp):[^ \t\n<>"]+[\w/]' => urlSub}
@@ -119,7 +189,7 @@
# outputs commit log comment text supplied by LogReader as preformatted HTML
class CommentHandler < LineConsumer
-@@ -661,6 +690,12 @@
+@@ -661,6 +706,12 @@
def diff(file)
'->'
end
@@ -132,7 +202,7 @@
end
# Superclass for objects that can link to CVS frontends on the web (ViewCVS,
-@@ -701,6 +736,14 @@
+@@ -701,6 +752,14 @@
"<a href=\"#{diff_url(file)}\">#{super(file)}</a>"
end
@@ -147,7 +217,7 @@
protected
def add_repo(url)
if @repository_name
-@@ -713,6 +756,10 @@
+@@ -713,6 +772,10 @@
url
end
end
@@ -158,7 +228,35 @@
end
# Link to ViewCVS
-@@ -771,6 +818,17 @@
+@@ -736,6 +799,15 @@
+ def diff_url(file)
+ add_repo("#{@base_url}#{urlEncode(file.path)}.diff?r1=#{file.fromVer}&r2=#{file.toVer}")
+ end
++
++ def log_url(file)
++ if file.toVer
++ log_anchor = "#rev#{file.toVer}"
++ else
++ log_anchor = ""
++ end
++ add_repo("#{@base_url}#{urlEncode(file.path)}#{log_anchor}")
++ end
+ end
+
+ # Link to Chora, from the Horde framework
+@@ -758,9 +830,9 @@
+ class CVSwebFrontend < WebFrontend
+ def path_url(path, tag)
+ if tag == nil
+- add_repo(@base_url + urlEncode(path))
++ add_repo(@base_url + urlEncode(path) + "/")
+ else
+- add_repo("#{@base_url}#{urlEncode(path)}?only_with_tag=#{urlEncode(tag)}")
++ add_repo("#{@base_url}#{urlEncode(path)}/?only_with_tag=#{urlEncode(tag)}")
+ end
+ end
+
+@@ -771,6 +843,17 @@
def diff_url(file)
add_repo("#{@base_url}#{urlEncode(file.path)}.diff?r1=text&tr1=#{file.fromVer}&r2=text&tr2=#{file.toVer}&f=h")
end
@@ -176,7 +274,7 @@
end
-@@ -792,6 +850,15 @@
+@@ -792,6 +875,15 @@
end
end
@@ -192,7 +290,7 @@
# Note when LogReader finds record of a file that was modified in this commit
class ModifiedFileHandler < FileHandler
def handleFile(file)
-@@ -801,6 +868,15 @@
+@@ -801,6 +893,15 @@
end
end
@@ -208,7 +306,16 @@
# Used by UnifiedDiffHandler to record the number of added and removed lines
# appearing in a unidiff.
-@@ -967,11 +1043,21 @@
+@@ -949,7 +1050,7 @@
+ end
+ shift(nil)
+ if @truncatedLineCount>0
+- println("<strong class=\"error\" title=\"#{@truncatedLineCount} lines truncated at column #{$maxDiffLineLength}\">[Note: Some over-long lines of diff output only partialy shown]</strong>")
++ println("<strong class=\"error\" title=\"#{@truncatedLineCount} lines truncated at column #{$maxDiffLineLength}\">[Note: Some over-long lines of diff output only partially shown]</strong>")
+ end
+ end
+
+@@ -967,11 +1068,21 @@
print($frontend.path($file.basedir, $file.tag))
println("</span><br />")
println("<div class=\"fileheader\" id=\"removed\"><big><b>#{htmlEncode($file.file)}</b></big> <small id=\"info\">removed after #{$frontend.version($file.path,$file.fromVer)}</small></div>")
@@ -230,7 +337,7 @@
end
print("<pre class=\"diff\"><small id=\"info\">")
lines.each do |line|
-@@ -1045,7 +1131,7 @@
+@@ -1045,7 +1156,7 @@
else
@stats.consume(line)
if $file.wants_diff_in_mail?
@@ -239,7 +346,7 @@
@colour.consume(line)
elsif @stats.diffLines == $maxLinesPerDiff
@colour.consume(line)
-@@ -1062,7 +1148,7 @@
+@@ -1062,7 +1173,7 @@
$file.isBinary = true
else
if $file.wants_diff_in_mail?
@@ -248,8 +355,41 @@
println("</pre>")
println("<strong class=\"error\">[truncated at #{$maxLinesPerDiff} lines; #{@stats.diffLines-$maxLinesPerDiff} more skipped]</strong>")
else
-@@ -1230,13 +1316,18 @@
+@@ -1172,7 +1283,7 @@
+
+ # an RFC 822 email address
+ class EmailAddress
+- def initialize(text)
++ def initialize(text, charset=nil)
+ if text =~ /^\s*([^<]+?)\s*<\s*([^>]+?)\s*>\s*$/
+ @personal_name = $1
+ @address = $2
+@@ -1180,9 +1291,10 @@
+ @personal_name = nil
+ @address = text
+ end
++ @charset=charset
+ end
+
+- attr_accessor :personal_name, :address
++ attr_accessor :personal_name, :address, :charset
+
+ def has_personal_name?
+ return !@personal_name.nil?
+@@ -1213,7 +1325,7 @@
+ # rfc2047 encode the word, if it contains non-ASCII characters
+ def encode_word(word)
+ if $encoder.requires_rfc2047?(word)
+- encoded = $encoder.marker_start_quoted
++ encoded = $encoder.marker_start_quoted(@charset)
+ $encoder.each_char_encoded(word) do |code|
+ encoded << code
+ end
+@@ -1228,18 +1340,28 @@
+ cvsroot_dir = "#{ENV['CVSROOT']}/CVSROOT"
+ $config = "#{cvsroot_dir}/cvsspam.conf"
$users_file = "#{cvsroot_dir}/users"
++$users_file_charset = nil
$debug = false
+$svn = false
@@ -267,8 +407,23 @@
+$wikiURL = nil
$jiraURL = nil
$ticketURL = nil
++$issueURL = nil
$viewcvsURL = nil
-@@ -1257,6 +1348,7 @@
++$xplannerIterationURL = nil
++$xplannerProjectURL = nil
++$xplannerStoryURL = nil
+ $choraURL = nil
+ $cvswebURL = nil
+ $from_address = nil
+@@ -1250,6 +1372,7 @@
+ # 2MiB limit on attached diffs,
+ $mail_size_limit = 1024 * 1024 * 2
+ $arg_charset = nil
++$cvsroot_email_header = false
+
+ require 'getoptlong'
+
+@@ -1257,6 +1380,7 @@
[ "--to", "-t", GetoptLong::REQUIRED_ARGUMENT ],
[ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ],
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
@@ -276,7 +431,7 @@
[ "--from", "-u", GetoptLong::REQUIRED_ARGUMENT ],
[ "--charset", GetoptLong::REQUIRED_ARGUMENT ]
)
-@@ -1265,6 +1357,7 @@
+@@ -1265,6 +1389,7 @@
$recipients << EmailAddress.new(arg) if opt=="--to"
$config = arg if opt=="--config"
$debug = true if opt=="--debug"
@@ -284,7 +439,7 @@
$from_address = EmailAddress.new(arg) if opt=="--from"
# must use different variable as the config is readed later.
$arg_charset = arg if opt == "--charset"
-@@ -1277,12 +1370,13 @@
+@@ -1277,12 +1402,13 @@
else
$stderr.puts "missing required file argument"
end
@@ -299,29 +454,44 @@
$additionalHeaders = Array.new
$problemHeaders = Array.new
-@@ -1343,12 +1437,21 @@
+@@ -1341,7 +1467,13 @@
+
+
if $bugzillaURL != nil
- commentSubstitutions['\b[Bb][Uu][Gg]\s*#?[0-9]+'] = bugzillaSub
- end
+- commentSubstitutions['\b[Bb][Uu][Gg]\s*#?[0-9]+'] = bugzillaSub
++ commentSubstitutions['\b[Bb](?:[Uu][Gg])?\s*[#:]?\s*\[?[0-9]+\]?'] = bugzillaSub
++end
+if $gforgeBugURL != nil
+ commentSubstitutions['\B\[#[0-9]+\]'] = gforgeBugSub
+end
+if $gforgeTaskURL != nil
+ commentSubstitutions['\B\[[Tt][0-9]+\]'] = gforgeTaskSub
-+end
+ end
if $jiraURL != nil
commentSubstitutions['\b[a-zA-Z]+-[0-9]+\b'] = jiraSub
- end
+@@ -1349,6 +1481,21 @@
if $ticketURL != nil
commentSubstitutions['\b[Tt][Ii][Cc][Kk][Ee][Tt]\s*#?[0-9]+\b'] = ticketSub
end
++if $issueURL != nil
++ commentSubstitutions['\b[Ii][Ss][Ss][Uu][Ee]\s*#?[0-9]+\b'] = issueSub
++end
+if $wikiURL != nil
+ commentSubstitutions['\[\[.+\]\]'] = wikiSub
+end
++if $xplannerIterationURL != nil
++ commentSubstitutions['\bXI\[?[0-9]+\]?'] = xplannerIterationSub
++end
++if $xplannerProjectURL != nil
++ commentSubstitutions['\bXP\[?[0-9]+\]?'] = xplannerProjectSub
++end
++if $xplannerStoryURL != nil
++ commentSubstitutions['\bXS\[?[0-9]+\]?'] = xplannerStorySub
++end
$commentEncoder = MultiSub.new(commentSubstitutions)
-@@ -1359,12 +1462,16 @@
+@@ -1359,12 +1506,16 @@
"T" => tagHandler,
"A" => AddedFileHandler.new,
"R" => RemovedFileHandler.new,
@@ -338,7 +508,7 @@
$fileEntries = Array.new
$task_list = Array.new
-@@ -1374,7 +1481,8 @@
+@@ -1374,7 +1525,8 @@
$diff_output_limiter = OutputSizeLimiter.new(mail, $mail_size_limit)
@@ -348,7 +518,7 @@
until reader.eof
handler = $handlers[reader.currentLineCode]
-@@ -1383,11 +1491,16 @@
+@@ -1383,11 +1535,16 @@
end
handler.handleLines(reader.getLines, $diff_output_limiter)
end
@@ -366,7 +536,7 @@
end
if $files_in_subject
-@@ -1434,13 +1547,15 @@
+@@ -1434,13 +1591,15 @@
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
@@ -383,7 +553,7 @@
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
-@@ -1466,7 +1581,9 @@
+@@ -1466,7 +1625,9 @@
filesAdded = 0
filesRemoved = 0
@@ -393,7 +563,7 @@
totalLinesAdded = 0
totalLinesRemoved = 0
file_count = 0
-@@ -1475,24 +1592,26 @@
+@@ -1475,24 +1636,26 @@
$fileEntries.each do |file|
unless file.repository == last_repository
last_repository = file.repository
@@ -431,7 +601,7 @@
end
end
mail.puts("</td></tr>")
-@@ -1507,8 +1626,12 @@
+@@ -1507,8 +1670,12 @@
filesAdded += 1
elsif file.removal?
filesRemoved += 1
@@ -444,7 +614,7 @@
end
name = htmlEncode(file.name_after_common_prefix)
slashPos = name.rindex("/")
-@@ -1528,17 +1651,29 @@
+@@ -1528,17 +1695,29 @@
name = "<span id=\"added\">#{name}</span>"
elsif file.removal?
name = "<span id=\"removed\">#{name}</span>"
@@ -479,7 +649,7 @@
if file.lineAdditions>0
totalLinesAdded += file.lineAdditions
mail.print("<td align=\"right\" id=\"added\">+#{file.lineAdditions}</td>")
-@@ -1565,15 +1700,19 @@
+@@ -1565,15 +1744,19 @@
mail.print("<td nowrap=\"nowrap\" align=\"right\">added #{$frontend.version(file.path,file.toVer)}</td>")
elsif file.removal?
mail.print("<td nowrap=\"nowrap\">#{$frontend.version(file.path,file.fromVer)} removed</td>")
@@ -500,7 +670,7 @@
if totalLinesAdded>0
mail.print("<td align=\"right\" id=\"added\">+#{totalLinesAdded}</td>")
else
-@@ -1590,7 +1729,7 @@
+@@ -1590,7 +1773,7 @@
mail.puts("</table>")
@@ -509,7 +679,7 @@
if totalFilesChanged > 1
mail.print("<small id=\"info\">")
changeKind = 0
-@@ -1603,11 +1742,21 @@
+@@ -1603,11 +1786,21 @@
mail.print("#{filesRemoved} removed")
changeKind += 1
end
@@ -531,7 +701,36 @@
mail.print(", total #{totalFilesChanged}") if changeKind > 1
mail.puts(" files</small><br />")
end
-@@ -1742,7 +1891,7 @@
+@@ -1655,7 +1848,7 @@
+ io.each_line do |line|
+ if line =~ /^([^:]+)\s*:\s*(['"]?)([^\n\r]+)(\2)/
+ if email.address == $1
+- return EmailAddress.new($3)
++ return EmailAddress.new($3, $users_file_charset)
+ end
+ end
+ end
+@@ -1669,6 +1862,8 @@
+ # sensible header formatting, and for ensuring that the body is seperated
+ # from the message headers by a blank line (as it is required to be).
+ class MailContext
++ ENCODE_HEADERS = ["Subject", "X-CVSspam-Module-Path"]
++
+ def initialize(io)
+ @done_headers = false
+ @io = io
+@@ -1678,8 +1873,8 @@
+ # called
+ def header(name, value)
+ raise "headers already commited" if @done_headers
+- if name == "Subject"
+- $encoder.encode_header(@io, "Subject", value)
++ if ENCODE_HEADERS.include?(name)
++ $encoder.encode_header(@io, name, value)
+ else
+ @io.puts("#{name}: #{value}")
+ end
+@@ -1742,7 +1937,7 @@
from = EmailAddress.new(ENV['USER'] || ENV['USERNAME'] || 'cvsspam')
end
unless from.address =~ /@/
@@ -540,7 +739,14 @@
end
smtp = Net::SMTP.new(@smtp_host)
blah("connecting to '#{@smtp_host}'")
-@@ -1758,6 +1907,40 @@
+@@ -1752,12 +1947,46 @@
+ ctx.header("To", recipients.map{|addr| addr.encoded}.join(','))
+ blah("Mail From: <#{from}>")
+ ctx.header("From", from.encoded) if from
+- ctx.header("Date", Time.now.utc.strftime(DATE_HEADER_FORMAT))
++ ctx.header("Date", Time.now.rfc2822)
+ yield ctx
+ end
end
end
@@ -581,7 +787,7 @@
if $smtp_host
require 'net/smtp'
mailer = SMTPMailer.new($smtp_host)
-@@ -1769,6 +1952,7 @@
+@@ -1769,6 +1998,7 @@
mailer.send($from_address, $recipients) do |mail|
mail.header("Subject", mailSubject)
@@ -589,6 +795,22 @@
mail.header("MIME-Version", "1.0")
mail.header("Content-Type", "text/html" + ($charset.nil? ? "" : "; charset=\"#{$charset}\""))
if ENV['REMOTE_HOST']
+@@ -1782,6 +2012,14 @@
+ end
+ end
+ mail.header("X-Mailer", "CVSspam #{$version} <http://www.badgers-in-foil.co.uk/projects/cvsspam/>")
++ if $cvsroot_email_header
++ mod = '/'
++ if Repository.count == 1
++ rep = Repository.array.first
++ mod << rep.common_prefix
++ end
++ mail.header("X-CVSspam-Module-Path", mod)
++ end
+
+ mail.body do |body|
+ make_html_email(body)
+
--- cvsspam-0.2.12/svn_post_commit_hook.rb 2005-07-11 18:53:29.000000000 +0300
+++ cvsspam/cvsspam-svn/svn_post_commit_hook.rb 2008-08-07 17:27:52.628725224 +0300
@@ -34,7 +34,7 @@
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/cvsspam-svnspam-branch.diff?r1=1.2&r2=1.3&f=u
More information about the pld-cvs-commit
mailing list