Last active
May 3, 2017 06:31
-
-
Save xoebus/e480f25524d4121b0322478cb3ea1caf to your computer and use it in GitHub Desktop.
a script to convert dep files to bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'toml' | |
def standard_name(name) | |
parts = name.split("/", 2) | |
domain = parts[0].split(".").reverse.join("_") | |
path = parts[1].split("/").join("_") | |
"#{domain}_#{path}".gsub("-", "_").gsub(".", "_") | |
end | |
projects = TOML.load_file("Gopkg.lock").fetch("projects") | |
projects.each do |p| | |
name = p.fetch("name") | |
puts "new_go_repository(" | |
puts " name = \"#{standard_name(name)}\"," | |
puts " commit = \"#{p.fetch("revision")}\"," | |
puts " importpath = \"#{name}\"," | |
puts ")" | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment