migrate_ghqroot_to_gopath
require "fileutils" | |
GOPATH = ENV["GOPATH"] | |
GO_SRC_PATH = GOPATH + "/src/github.com" | |
GHQ_ROOT = "/Users/tomohiro/.ghq/github.com" | |
def mv(src, dest) | |
# puts "mv #{src} #{dest}" | |
FileUtils.mv src, dest | |
end | |
Dir["#{GHQ_ROOT}/**"].each do |file| | |
dest_dir = "#{GO_SRC_PATH}/#{File.basename(file)}" | |
unless File.exists?(dest_dir) | |
mv file, dest_dir | |
next | |
end | |
Dir["#{file}/**"].each do |dir| | |
dest_dir2 = "#{dest_dir}/#{File.basename(dir)}" | |
if File.exists?(dest_dir2) | |
warn "error: #{dest_dir2}" | |
next | |
end | |
mv dir, dest_dir2 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment