match/lib/match/nuke.rb in fastlane_hotfix-2.165.1 vs match/lib/match/nuke.rb in fastlane_hotfix-2.187.0

- old
+ new

@@ -34,10 +34,15 @@ shallow_clone: params[:shallow_clone], skip_docs: params[:skip_docs], git_branch: params[:git_branch], git_full_name: params[:git_full_name], git_user_email: params[:git_user_email], + + git_private_key: params[:git_private_key], + git_basic_authorization: params[:git_basic_authorization], + git_bearer_authorization: params[:git_bearer_authorization], + clone_branch_directly: params[:clone_branch_directly], google_cloud_bucket_name: params[:google_cloud_bucket_name].to_s, google_cloud_keys_file: params[:google_cloud_keys_file].to_s, google_cloud_project_id: params[:google_cloud_project_id].to_s, s3_region: params[:s3_region].to_s, @@ -95,13 +100,15 @@ params.option_for_key(:git_url).optional = true end end def spaceship_login - if api_token + if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path])) UI.message("Creating authorization token for App Store Connect API") Spaceship::ConnectAPI.token = api_token + elsif !Spaceship::ConnectAPI.token.nil? + UI.message("Using existing authorization token for App Store Connect API") else Spaceship::ConnectAPI.login(params[:username], use_portal: true, use_tunes: false, portal_team_id: params[:team_id], team_name: params[:team_name]) end if Spaceship::ConnectAPI.client.in_house? && (type == "distribution" || type == "enterprise") @@ -113,16 +120,10 @@ UI.user_error!("Enterprise account nuke cancelled") unless UI.confirm("Do you really want to nuke your Enterprise account?") end end - def api_token - @api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key] - @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path] - return @api_token - end - # Collect all the certs/profiles def prepare_list UI.message("Fetching certificates and profiles...") cert_type = Match.cert_type_sym(type) cert_types = [cert_type] @@ -244,20 +245,23 @@ UI.message(ex.to_s) end UI.success("Successfully deleted certificate") end - if self.files.count > 0 - files_to_delete = delete_files! - end + files_to_delete = delete_files! if self.files.count > 0 + files_to_delete ||= [] self.encryption.encrypt_files if self.encryption - # Now we need to commit and push all this too - message = ["[fastlane]", "Nuked", "files", "for", type.to_s].join(" ") - self.storage.save_changes!(files_to_commit: [], - files_to_delete: files_to_delete, - custom_message: message) + if files_to_delete.count > 0 + # Now we need to save all this to the storage too, if needed + message = ["[fastlane]", "Nuked", "files", "for", type.to_s].join(" ") + self.storage.save_changes!(files_to_commit: [], + files_to_delete: files_to_delete, + custom_message: message) + else + UI.message("Your storage had no files to be deleted. This happens when you run `nuke` with an empty storage. Nothing to be worried about!") + end end private def delete_files!