Skip to content

Instantly share code, notes, and snippets.

@ograycode
Created May 4, 2017 20:51
Show Gist options
  • Select an option

  • Save ograycode/da3a31656d75549cbd9d1d57d9926c49 to your computer and use it in GitHub Desktop.

Select an option

Save ograycode/da3a31656d75549cbd9d1d57d9926c49 to your computer and use it in GitHub Desktop.
Find matching configs between heroku apps
=begin
Usage: ruby matching_configs <app1> <app2>
=end
require 'json'
first_app_name = ARGV[0]
second_app_name = ARGV[1]
puts "Finding matches for #{first_app_name} -> #{second_app_name}"
first_app = JSON.load %x(heroku config --json --app #{first_app_name})
second_app = JSON.load %x(heroku config --json --app #{second_app_name})
matched = []
first_app.each do |key, val|
if second_app.has_value? val
matched_keys = second_app.select { |k, v| v == val }
matched.push("#{key} -> #{matched_keys.keys.count == 1 ? matched_keys.keys[0] : matched_keys.keys}")
end
end
puts "------------------------"
puts matched
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment