Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
Remove broken sync_consul_deps
Browse files Browse the repository at this point in the history
This code won't work anymore, and should the team update Consul, won't be
needed anymore either now that both p2 and consul use `go mod` for dependency
management.
  • Loading branch information
mcpherrinm committed Aug 8, 2019
1 parent d23dcd0 commit 1062fcc
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,66 +80,3 @@ end

desc 'By default, gather dependencies, build and test'
task :default => [:deps, :test, :install]

task :sync_consul_deps do
p2_repo_dir = File.join(ENV["GOPATH"], "src", "github.com", "square", "p2")

consul_vendor_contents = JSON.parse(File.read(File.join(ENV["GOPATH"], "src", "github.com", "hashicorp", "consul", "vendor", "vendor.json")))
p2_godep_contents = JSON.parse(File.read(File.join(p2_repo_dir, "Godeps", "Godeps.json")))

# build a map of package names to revisions from consul's vendor.json
consul_deps = {}
consul_vendor_contents["package"].each do |package|
consul_deps[package["path"]] = package["revision"]
end

success_count = 0
failed_count = 0
skipped_count = 0

# now iterate over our Godeps.json and find any versions that mismatch and print them
p2_godep_contents["Deps"].each do |package|
package_name = package["ImportPath"]
consul_rev = consul_deps[package_name]
next unless consul_rev

our_rev = package["Rev"]
if consul_rev != our_rev
# grab just the first three items e.g. github.com/hashicorp/consul not github.com/hashicorp/consul/api/inner/package/thing
first_three = package_name.split("/")[0..2]
first_three_joined = first_three.join("/")

# in case the consul dependency is new and not in $GOPATH, do a "go get" first
e "go get #{first_three_joined}/..."
begin
Dir.chdir(File.join(ENV["GOPATH"], "src", *first_three)) do
e "git fetch"
older_commit = `git merge-base #{our_rev} #{consul_rev}`.chomp
raise "could not determine which commit is newer for #{first_three_joined}" unless $?.exitstatus == 0
if older_commit == our_rev
e "git checkout #{consul_rev}"
else
puts "No action taken for #{package_name}: consul's version #{consul_rev} is older than P2's #{our_rev}"
skipped_count += 1
next
end
end

Dir.chdir(p2_repo_dir) do
e "godep update #{first_three.join("/")}/..."
end

puts "Successfully repaired mismatch in #{package_name}: consul has #{consul_rev} p2 had #{our_rev}"
success_count += 1
rescue => e
puts "Failed to repair mismatch in #{package_name}: consul has #{consul_rev} p2 had #{our_rev}: #{e.message}"
failed_count += 1
end

end
end

puts "Successfully updated #{success_count} packages"
puts "Failed to updated #{failed_count} packages"
puts "Skipped updating #{skipped_count} packages (because consul had an older version vendored)"
end

0 comments on commit 1062fcc

Please sign in to comment.