Created
June 30, 2010 02:39
-
-
Save danlynn/458157 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| committers = Hash.new(0) | |
| log.reverse_each do |line| | |
| if line =~ /^\w+? \| (\w+?) \| (.+?) \(.+?\) \| / | |
| first_commit_time ||= Time.parse($2) | |
| committers[$1] += (Time.parse($2) - first_commit_time) / 86400 | |
| end | |
| 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