Skip to content

Instantly share code, notes, and snippets.

@NigelThorne
Created November 29, 2011 02:31
Show Gist options
  • Save NigelThorne/1403103 to your computer and use it in GitHub Desktop.
Save NigelThorne/1403103 to your computer and use it in GitHub Desktop.
SVN log to CSV ["Revision","Author","Date","Message","Jira Issues Mentioned..."]
# Report SVN logs for a revision span as a csv for analysis in excel.
# By Nigel Thorne (nwt) www.nigelthorne.com
require 'nokogiri'
repo = ARGV[0] || "http://.../trunk" # repository location
from = ARGV[1] || "1111" # from revision
to = ARGV[2] || "2222" # to revision
xml_changes = Nokogiri::XML(`svn.exe log #{repo} -r#{from}:#{to} --xml`)
def csv(*args)
args.map{|a| "\"#{(a||'').to_s.gsub(/"/,'""')}\""}.join(",")
end
@jiras = Hash.new([])
puts csv("Revision","Author","Date","Message","Jira Issues Mentioned...")
(xml_changes/("logentry")).map {|change|
[change.attr('revision'), (change/'author').text, (change/'date').text, (change/'msg').text] + (change/'msg').text.scan(/ADV-? ?_?[0-9]+/i).uniq
}.each{|args|
args[3].scan(/ADV-? ?_?[0-9]+/i).uniq.each{|jira| @jiras[jira] += [args[0],args[1]]} #record jira to Issue map
puts csv(*args)
}
puts "\n\n\nJIRAS\n\n\n"
@jiras.each{|k,v|
puts csv(*([k]+v))
}
@NigelThorne
Copy link
Author

Pipe to a file and open in excel. Make sure svn.exe is on your path.
Only use if you understand the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment