|
# Koffeinfrei svn_authors.rb |
|
# Copyright (C) 2011 Alexis Reigel |
|
# |
|
# This program is free software: you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation, either version 3 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# This program is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
require 'optparse' |
|
require 'active_support/inflector' |
|
|
|
options = { :domain => 'DOMAIN' } |
|
OptionParser.new do |opts| |
|
opts.banner = "Usage: #{$0} [options]" |
|
|
|
opts.on("-u", "--url URL", "Specify a svn repository url, unless you are inside a working copy.") do |url| |
|
options[:url] = url |
|
end |
|
opts.on("-r", "--revision REVISION", "Specify the revision range, e.g. 1234:HEAD") do |revision| |
|
options[:revision] = revision |
|
end |
|
opts.on("-g", "--git", "Output in git user format (for conversion to git)") do |
|
options[:git] = true |
|
end |
|
opts.on("--guess", "Guess the name and new email address") do |
|
options[:guess] = true |
|
end |
|
opts.on("-d", "--domain DOMAIN", "The domain for the new email addresses") do |domain| |
|
options[:domain] = domain |
|
end |
|
opts.on_tail("-h", "--help", "Show this message") do |
|
puts opts |
|
exit |
|
end |
|
end.parse! |
|
|
|
authors = `svn log #{options[:url]} -q#{' -r ' + options[:revision] if options[:revision]}` |
|
.split(/\n/) |
|
.select{ |x| x.include? "|" } |
|
.collect { |x| x.split("|")[1].strip } |
|
.uniq |
|
.sort |
|
|
|
if (options[:git]) |
|
puts authors.collect{ |x| options[:guess] ? "#{x} = #{x.sub('.', ' ').titleize} <#{x.downcase}@#{options[:domain]}>" : "#{x} = NAME <USER@#{options[:domain]}>" } |
|
else |
|
puts authors |
|
end |