Skip to content

Instantly share code, notes, and snippets.

@Sixeight
Created June 25, 2014 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sixeight/d64d3de43d3afd89e719 to your computer and use it in GitHub Desktop.
Save Sixeight/d64d3de43d3afd89e719 to your computer and use it in GitHub Desktop.
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