Skip to content

Instantly share code, notes, and snippets.

@danlynn
Created June 30, 2010 02:20
Show Gist options
  • Select an option

  • Save danlynn/458131 to your computer and use it in GitHub Desktop.

Select an option

Save danlynn/458131 to your computer and use it in GitHub Desktop.
# call-seq
# get_owner_from_svn_log(Pathname("path/to/source.java")) => owner_name
#
# if 'pathname' doesn't exist or there is no commit history then returns nil
def self.get_owner_from_svn_log(pathname)
log = `svn log #{pathname}`
first_commit_time = nil
commits = []
log.each do |line|
commits << [$1, first_commit_time = Time.parse($2)] if line =~ /^\w+? \| (\w+?) \| (.+?) \(.+?\) \| /
end
committers = Hash.new(0)
commits.each do |commit|
committers[commit[0]] += (commit[1] - first_commit_time) / 86400
end
committers.sort {|a,b| a[1] <=> b[1]}.last[0] rescue nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment