Skip to content

Instantly share code, notes, and snippets.

@Sixeight

Sixeight/cat.rb

Created Jun 25, 2014
Embed
What would you like to do?
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