match/lib/match/storage/interface.rb in fastlane-2.219.0 vs match/lib/match/storage/interface.rb in fastlane-2.220.0

- old
+ new

@@ -53,15 +53,18 @@ # that's optional, is used for commit title def save_changes!(files_to_commit: nil, files_to_delete: nil, custom_message: nil) # Custom init to `[]` in case `nil` is passed files_to_commit ||= [] files_to_delete ||= [] + files_to_delete -= files_to_commit # Make sure we are not removing added files. + if files_to_commit.count == 0 && files_to_delete.count == 0 + UI.user_error!("Neither `files_to_commit` nor `files_to_delete` were provided to the `save_changes!` method call") + end + Dir.chdir(File.expand_path(self.working_directory)) do if files_to_commit.count > 0 # everything that isn't `match nuke` - UI.user_error!("You can't provide both `files_to_delete` and `files_to_commit` right now") if files_to_delete.count > 0 - if !File.exist?(MATCH_VERSION_FILE_NAME) || File.read(MATCH_VERSION_FILE_NAME) != Fastlane::VERSION.to_s files_to_commit << MATCH_VERSION_FILE_NAME File.write(MATCH_VERSION_FILE_NAME, Fastlane::VERSION) # stored unencrypted end @@ -72,16 +75,17 @@ File.write(readme_path, template) end self.upload_files(files_to_upload: files_to_commit, custom_message: custom_message) UI.message("Finished uploading files to #{self.human_readable_description}") - elsif files_to_delete.count > 0 + end + + if files_to_delete.count > 0 self.delete_files(files_to_delete: files_to_delete, custom_message: custom_message) UI.message("Finished deleting files from #{self.human_readable_description}") - else - UI.user_error!("Neither `files_to_commit` nor `files_to_delete` were provided to the `save_changes!` method call") end end + ensure # Always clear working_directory after save self.clear_changes end def upload_files(files_to_upload: [], custom_message: nil) not_implemented(__method__)