https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
Add two commands `url' and `script'.
* vcs/lib/vcs/url.rb: New. Just extract the url from the info command.
* vcs/lib/vcs/script.rb: New.
Provides a simple but powerful way to make custom request from your
favorite version control system, this method takes a ruby block code
and evaluate it in your vcs instance context.
script.rb | 19 +++++++++++++++++++
url.rb | 16 ++++++++++++++++
2 files changed, 35 insertions(+)
Index: vcs/lib/vcs/script.rb
--- vcs/lib/vcs/script.rb (revision 0)
+++ vcs/lib/vcs/script.rb (revision 0)
@@ -0,0 +1,19 @@
+# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>.
+# Copyright:: Copyright (c) 2005 LRDE. All rights reserved.
+# License:: GNU General Public License (GPL).
+# Revision:: $Id$
+
+require 'vcs/vcs'
+
+class Vcs
+
+ def script! ( code, *args )
+ begin
+ eval(code)
+ rescue Exception => ex
+ LOG.error { 'Vcs#script: during the client execution' }
+ LOG.error { ex.long_pp }
+ end
+ end
+
+end # class Svn
Property changes on: vcs/lib/vcs/script.rb
___________________________________________________________________
Name: svn:keywords
+ Id
Index: vcs/lib/vcs/url.rb
--- vcs/lib/vcs/url.rb (revision 0)
+++ vcs/lib/vcs/url.rb (revision 0)
@@ -0,0 +1,16 @@
+# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>.
+# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
+# License:: GNU General Public License (GPL).
+# Revision:: $Id$
+
+require 'vcs/svn'
+
+class Svn
+
+ def url! ( *args )
+ puts info.read[/^URL:\s+(.*)$/, 1]
+ end
+
+ alias_command :date, :last_changed_date
+
+end # class Svn
Property changes on: vcs/lib/vcs/url.rb
___________________________________________________________________
Name: svn:keywords
+ Id
https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
A nice way to fill the subject and the news of your patches.
* vcs/lib/vcs/message.rb: Display the url on top of the ChangeLog entry.
* vcs/lib/vcs/changelog.rb, vcs/lib/vcs/mycommit.rb:
No more takes the subject as argument, provide a nice way to set the
subject of your mail and the title of your patch.
changelog.rb | 90 ++++++++++++++++++++++++++++++++++++++++++++---------------
message.rb | 8 +++--
mycommit.rb | 18 +++++++----
3 files changed, 84 insertions(+), 32 deletions(-)
Index: vcs/lib/vcs/changelog.rb
--- vcs/lib/vcs/changelog.rb (revision 219)
+++ vcs/lib/vcs/changelog.rb (working copy)
@@ -48,29 +48,67 @@
end
end
+ @@subject_format = '<%= rev %>: <%= title %>'
+
def mkchangelog! ( *args )
error_handling :changelog_failed
+ unless CL.exist?
+ raise Failure, "No `#{CL}', you are probably not in a valid directory."
+ end
+
cl = ADD_CL
+ # Already filled if ,ChangeLog.add exists and not begin by ---
if cl.exist?
- f = cl.open('r')
- if f.readline !~ /^===/
- f.rewind
- return f
+ raise MustBeFilled, cl if cl.read =~ /\A---/
+ require 'erb'
+ ls = []
+ YAML.each_document(cl.read) { |x| (ls.size == 2)? break : ls << x }
+ header, input = ls
+ rev = revision.read.to_i
+ header.merge!('rev' => rev, 'revision' => rev)
+ header['title'].sub!(/\.$/, '')
+ b = getBinding(header)
+ header = ERB.new(header.to_yaml, $SAFE, '<-%->', '$erbout_').result(b)
+ META.open('w') { |f| f.puts header }
+ output = ERB.new(input, $SAFE, '<-%->', '$erbout_').result(b)
+ return output
end
- f.close
- else
+
cl_add = mkchangelog_from_status(*args)
LOG.info "Creating a new `#{cl}' file"
cl.open('w') do |f|
- f.puts '=== Fill this file correctly and remove this line ==='
- f.puts Time.now.strftime("%Y-%m-%d #{FULL_EMAIL}")
- f.puts
+ head = Time.now.strftime("%Y-%m-%d #{FULL_EMAIL}")
+ f.puts "
+|--- | ########## Fill this file correctly and remove this line ########## | ---
+|title:
+|subject: '#{@@subject_format}.'
+|
+|--- | ###################### Your ChangeLog entrie ###################### | ---
+ |#{head}
+ |
+ |\t<%= title %>.
+ |
+ |".head_cut!
+
cl_add.each do |file, str|
f.puts "\t* #{file}: #{str}."
end
- end
+
+ f.puts "|
+|--- | ########### This line, and those below, will be ignored ########### | ---
+ |Instructions:
+ |\t* The first line must be removed when this file is filled.
+ |\t* After you must specify a title, for the news/mail subject.
+ |\t* The line containing <%= title %> will be replaced by your title,
+ |\t <%= subject %> by the subject line, <%= rev %> by the revision...
+ |\t* Everywhere in the document you can get/compute some values with
+ |\t these tags <%= aRubyExpression %> even some vcs specific call.
+ |\t For example <%= status.read %> will include the `svn status' output.
+ |
+ |".head_cut!
+ with(f).diff!(*args)
end
raise MustBeFilled, cl
@@ -79,11 +117,7 @@
def concat_changelog! ( *args )
error_handling :changelog_failed
- unless CL.exist?
- raise Failure, "No `#{CL}', you are probably not in a valid directory."
- end
-
- if cl = mkchangelog(*args)
+ if cl_entry = mkchangelog(*args)
unless TMP_CL.exist?
LOG.info "Moving `#{CL}' to `#{TMP_CL}' ..."
@@ -92,11 +126,13 @@
CL.open('w') do |file|
LOG.info "Prepending `#{ADD_CL}' to `#{CL}' ..."
- file.print cl.read
+ file.print cl_entry
file.puts
file.print TMP_CL.read
end
+ return cl_entry
+
end
end
@@ -108,6 +144,16 @@
LOG.info "#{ADD_CL}: Contains your ChangeLog entry" if ADD_CL.exist?
end
+ def getBinding ( header )
+ code = []
+ header.each do |k, v|
+ code << "#{k} = #{v.inspect}"
+ end
+ code << 'binding'
+ eval(code.join('; '))
+ end
+ protected :getBinding
+
alias_command :mkcl, :mkchangelog
alias_command :ctcl, :concat_changelog
Index: vcs/lib/vcs/mycommit.rb
--- vcs/lib/vcs/mycommit.rb (revision 219)
+++ vcs/lib/vcs/mycommit.rb (working copy)
@@ -12,10 +12,12 @@
COMMITED = Pathname.new(',commited')
- def common_commit! ( *args, &block )
+ def common_commit! ( subject_format, *args, &block )
opts, args = args.partition { |a| a =~ /^-/ }
+ @@subject_format = subject_format
+
update!
unless COMMITED.exist?
@@ -34,14 +36,16 @@
commit_failed
end
- concat_changelog!(*args)
+ cl_entry = concat_changelog!(*args)
#pager! diff
#pager! status
args << 'ChangeLog' unless args.grep(/^[^-]/).empty?
- if commit!('-F', ADD_CL, *(opts + args))
+ # FIXME simplify cl_entry contents
+
+ if commit!('--message', cl_entry, *(opts + args))
ADD_CL.rename(COMMITED)
TMP_CL.delete if TMP_CL.exist?
else
@@ -57,18 +61,18 @@
end
+ header ||= YAML::load(META.read)
- rev = revision.read.to_i
-
- block.call(rev) if block_given?
+ block[header['subject']] if block_given?
LOG.info 'Deleting junk files...'
TMP_CL.delete if TMP_CL.exist?
ADD_CL.delete if ADD_CL.exist?
COMMITED.delete if COMMITED.exist?
+ META.delete if META.exist?
messages = Pathname.new(',messages')
messages.mkpath unless messages.directory?
- message_rev = messages + "#{@@message}.#{rev}"
+ message_rev = messages + "#{@@message}.#{header['rev']}"
LOG.info "Moving `#{@@message}' to `#{message_rev}'..."
@@message.rename(message_rev)
LOG.info "You can remove `#{message_rev}' if everything is ok."
Index: vcs/lib/vcs/message.rb
--- vcs/lib/vcs/message.rb (revision 219)
+++ vcs/lib/vcs/message.rb (working copy)
@@ -39,13 +39,15 @@
error_handling :message_failed
unless @@message.exist?
- cl = mkchangelog(*args)
+ cl_entry = mkchangelog(*args)
TempPath.new('message') do |tmp|
tmp.open('w') do |f|
+ with(f).url!
+ f.puts
f.puts 'Index: ChangeLog'
- f.print cl.read.sub(/^\d+-\d+-\d+/, 'from')
+ f.print cl_entry.sub(/^\d+-\d+-\d+/, 'from')
f.puts
- f.print diffstat(*args).read
+ with(f).diffstat!(*args)
f.puts
diffw_from_status(*args).each_line do |line|
f.print line if line !~ /^=+$/
Spam detection software, running on the system "kualalumpur.lrde.epita.fr", has
identified this incoming email as possible spam. The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email. If you have any questions, see
the administrator of that system for details.
Content preview: Fast erection Prolonged effect No prescription
required 2 popular medicines: CIALIS - http://www.get-a-pill.com/sv/
VIAGRA - http://www.get-a-pill.com/vt/ Discreet packaging [...]
Content analysis details: (15.5 points, 5.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
1.2 RCVD_NUMERIC_HELO Received: contains an IP address used for HELO
0.2 DRUG_ED_CAPS BODY: Mentions an E.D. drug
0.0 HTML_MESSAGE BODY: HTML included in message
0.1 HTML_TAG_EXIST_TBODY BODY: HTML has "tbody" tag
0.1 RAZOR2_CF_RANGE_51_100 BODY: Razor2 gives confidence level above 50%
[cf: 100]
3.5 BAYES_99 BODY: Bayesian spam probability is 99 to 100%
[score: 1.0000]
0.1 HTML_50_60 BODY: Message is 50% to 60% HTML
1.5 RAZOR2_CHECK Listed in Razor2 (http://razor.sf.net/)
1.0 URIBL_SBL Contains an URL listed in the SBL blocklist
[URIs: get-a-pill.com]
3.2 URIBL_OB_SURBL Contains an URL listed in the OB SURBL blocklist
[URIs: get-a-pill.com]
4.3 URIBL_SC_SURBL Contains an URL listed in the SC SURBL blocklist
[URIs: get-a-pill.com]
0.2 DRUGS_ERECTILE Refers to an erectile drug
0.1 FORGED_OUTLOOK_TAGS Outlook can't send HTML in this format
The original message was not completely plain text, and may be unsafe to
open with some email clients; in particular, it may contain a virus,
or confirm that your address can receive spam. If you wish to view
it, it may be safer to save it to a file and open it with an editor.