1 #!/usr/bin/env ruby -KU
3 ENV["PATH"] = "/usr/local/bin/:/opt/local/bin:#{ENV["PATH
"]}"
4 ENV["RAILS_ENV"] ||= "production"
5 require File
.dirname(__FILE__
) + "/../config/environment"
9 NOOP
= ARGV[0] == "dry-run"
12 Repository
.all
.each
do |repo
|
14 next if File
.exist
?(repo
.full_repository_path
)
17 path
= File
.join(repo
.project
.slug
, "#{repo.name}.git")
19 path
= File
.join(repo
.owner
.to_param
, "#{repo.name}.git")
21 say
"no path for #{repo.inspect}"
24 full_path
= File
.join(RepositoryRoot
.default_base_path
, path
)
25 full_target_path
= File
.join(RepositoryRoot
.default_base_path
, "#{repo.full_hashed_path}.git")
26 unless File
.exist
?(full_path
)
27 $stderr.puts
"\e[1;31m#{path.inspect} doesn't exist!\e[0m"
30 #p "#{path} => #{repo.full_hashed_path}.git"
31 base_dir
= full_target_path
.split("/")[0..-2].join("/")
32 unless File
.exist
?(base_dir
)
33 FileUtils
.mkdir_p(base_dir
, :verbose => true, :noop => NOOP
)
35 FileUtils
.mv full_path
, full_target_path
, :verbose => true, :noop => NOOP
38 FileUtils
.rm(File
.join(full_target_path
, "hooks"), :verbose => true, :noop => NOOP
)
39 hooks_src
= File
.join(RepositoryRoot
.default_base_path
, ".hooks")
40 hooks_dest
= File
.join(full_target_path
, "hooks")
41 FileUtils
.ln_s(hooks_src
, hooks_dest
, :verbose => true, :noop => NOOP
)
43 fails
<< [repo
.id
, e
.class.name
, e
.message
, e
.backtrace
.join("\n ")]