comparison extra/soundsoftware/create-repo-authormaps.rb @ 1540:322d7b57e5f0 live

Making this work through the api is too complicated for now; this will do OK
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 02 Jun 2015 10:58:31 +0100
parents 22d57b0e0a77
children 60acfbd8f6d6
comparison
equal deleted inserted replaced
1539:22d57b0e0a77 1540:322d7b57e5f0
16 # /var/repo-export/authormap/authormap_repo_3 16 # /var/repo-export/authormap/authormap_repo_3
17 # 17 #
18 # This script does that, if given the two directory names as arguments 18 # This script does that, if given the two directory names as arguments
19 # to the -s and -o options. In the above example: 19 # to the -s and -o options. In the above example:
20 # 20 #
21 # create-repo-authormaps.rb -s /var/hg -o /var/repo-export/authormap 21 # script/rails runner create-repo-authormaps.rb -s /var/hg -o /var/repo-export/authormap
22 # 22 #
23 # Note that this script will overwrite any existing authormap 23 # Note that this script will overwrite any existing authormap
24 # files. (That's why the output files are given an authormap_ prefix, 24 # files. (That's why the output files are given an authormap_ prefix,
25 # so we're less likely to clobber something else if the user gets the 25 # so we're less likely to clobber something else if the user gets the
26 # arguments wrong.) 26 # arguments wrong.)
54 if ($repos_base.empty? or $out_base.empty?) 54 if ($repos_base.empty? or $out_base.empty?)
55 usage 55 usage
56 end 56 end
57 57
58 unless File.directory?($repos_base) 58 unless File.directory?($repos_base)
59 log("input directory '#{$repos_base}' doesn't exist", :exit => true) 59 puts "input directory '#{$repos_base}' doesn't exist"
60 exit 1
60 end 61 end
61 62
62 unless File.directory?($out_base) 63 unless File.directory?($out_base)
63 log("output directory '#{$out_base}' doesn't exist", :exit => true) 64 puts "output directory '#{$out_base}' doesn't exist"
65 exit 1
64 end 66 end
65 67
66 projects = Project.find(:all) 68 projects = Project.find(:all)
67 69
68 if projects.nil? 70 if projects.nil?
69 log('No projects found', :exit => true) 71 puts 'No projects found'
72 exit 1
70 end 73 end
71 74
72 projects.each do |proj| 75 projects.each do |proj|
73 next unless proj.respond_to?(:repository) 76 next unless proj.respond_to?(:repository)
74 77
76 next if repo.nil? or repo.url.empty? 79 next if repo.nil? or repo.url.empty?
77 80
78 repo_url = repo.url 81 repo_url = repo.url
79 repo_url = repo_url.gsub(/^file:\/*/, "/"); 82 repo_url = repo_url.gsub(/^file:\/*/, "/");
80 if repo_url != File.join($repos_base, proj.identifier) 83 if repo_url != File.join($repos_base, proj.identifier)
81 log('Project #{proj.identifier} has repo in unsupported location #{repo_url}, skipping') 84 puts 'Project #{proj.identifier} has repo in unsupported location #{repo_url}, skipping'
82 next 85 next
83 end 86 end
84 87
85 csets = repo.changesets 88 csets = repo.changesets
86 committers = csets.map do |c| c.committer end.sort.uniq 89 committers = csets.map do |c| c.committer end.sort.uniq