Skip to content

Instantly share code, notes, and snippets.

@threez
Created March 24, 2011 16:57
Show Gist options
  • Save threez/885416 to your computer and use it in GitHub Desktop.
Save threez/885416 to your computer and use it in GitHub Desktop.
require "time"
class Commit
attr_accessor :revision, :author, :time, :lines, :comment
end
# parse input arguments
from = ARGV.shift.to_i
to = ARGV.shift.to_i
# clean svn log
svn_log = open("| svn log").read.lines.to_a
# convert to objects
commits = []
current = nil
for line in svn_log do
next if line.chomp =~ /^[-]*$/ # cleaning
if (parts = line.chomp.split(" | ")).size == 4
# meta
current = Commit.new
current.revision = parts[0].gsub("r", "").to_i
current.author = parts[1]
current.time = Time.parse(parts[2].split(" (").first)
current.lines = parts[3].to_i
current.comment = ""
commits << current
else
# comment
current.comment << line
end
end
# find objects
selection = commits.select do |commit|
(from..to) === commit.revision
end
if $0 == __FILE__
# print the commit messages
puts "Changelog for #{selection.size}/#{commits.size} commits (r#{from} to r#{to}): "
selection.each do |commit|
puts "[#{commit.revision} - #{commit.author}] #{commit.comment.chomp}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment