lib/preinstaller.rb in cocoapods-keys-1.4.0 vs lib/preinstaller.rb in cocoapods-keys-1.5.0

- old
+ new

@@ -15,20 +15,24 @@ ui = Pod::UserInterface options = @user_options || {} current_dir = Pathname.pwd project = options.fetch('project') { CocoaPodsKeys::NameWhisperer.get_project_name } - keyring = KeyringLiberator.get_keyring_named(project) || KeyringLiberator.get_keyring(current_dir) + keyring = KeyringLiberator.get_current_keyring(project, current_dir) + + unless keyring + check_for_multiple_keyrings(project, current_dir) + end + existing_keyring = !keyring.nil? keyring = CocoaPodsKeys::Keyring.new(project, current_dir, []) unless keyring - data = keyring.keychain_data has_shown_intro = false keys = options.fetch('keys', []) keys.each do |key| - unless ENV[key] || data.keys.include?(key) + unless keyring.keychain_has_key?(key) unless has_shown_intro ui.puts "\n CocoaPods-Keys has detected a keys mismatch for your setup." has_shown_intro = true end @@ -44,10 +48,25 @@ args = CLAide::ARGV.new([key, answer, keyring.name]) setter = Pod::Command::Keys::Set.new(args) setter.run end end + CocoaPodsKeys::KeyringLiberator.save_keyring(keyring) existing_keyring || !keys.empty? + end + + def check_for_multiple_keyrings(project, current_dir) + ui = Pod::UserInterface + keyrings = KeyringLiberator.get_all_keyrings_named(project) + if keyrings.count > 1 + ui.puts "Found multiple keyrings for project #{project.inspect}, but" + ui.puts "no match found for current path (#{current_dir}):" + keyrings.each do |found_keyring| + ui.puts "- #{found_keyring.path}" + end + ui.puts "\nPress enter to create a new keyring, or `ctrl + c` to cancel" + ui.gets + end end end end