From 1062fccd1dfe4840336b4939c79ed9ac8a459cf8 Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Thu, 8 Aug 2019 10:11:56 -0700 Subject: [PATCH] Remove broken sync_consul_deps 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. --- Rakefile | 63 -------------------------------------------------------- 1 file changed, 63 deletions(-) diff --git a/Rakefile b/Rakefile index 0aa047fa7..bc4e894fb 100644 --- a/Rakefile +++ b/Rakefile @@ -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