Sha256: de0796d3a9c26544ec84ac4f35b718c84b88351a72204332ebc371d62fbc6814

Contents?: true

Size: 1.78 KB

Versions: 55

Compression:

Stored size: 1.78 KB

Contents

require_relative 'module'

require_relative 'storage'
require_relative 'encryption'

module Match
  # These functions should only be used while in (UI.) interactive mode
  class ChangePassword
    def self.update(params: nil)
      if params[:storage_mode] != "git"
        # Only git supports changing the password
        # All other storage options will most likely use more advanced
        # ways to encrypt files
        UI.user_error!("Only git-based match allows you to change your password, current `storage_mode` is #{params[:storage_mode]}")
      end

      ensure_ui_interactive

      to = FastlaneCore::Helper.ask_password(message: "New passphrase for Git Repo: ", confirm: true)

      # Choose the right storage and encryption implementations
      storage = Storage.for_mode(params[:storage_mode], {
        git_url: params[:git_url],
        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],
        clone_branch_directly: params[:clone_branch_directly]
      })
      storage.download

      encryption = Encryption.for_storage_mode(params[:storage_mode], {
        git_url: params[:git_url],
        working_directory: storage.working_directory
      })
      encryption.decrypt_files

      encryption.clear_password
      encryption.store_password(to)

      message = "[fastlane] Changed passphrase"
      files_to_commit = encryption.encrypt_files
      storage.save_changes!(files_to_commit: files_to_commit, custom_message: message)
    end

    def self.ensure_ui_interactive
      raise "This code should only run in interactive mode" unless UI.interactive?
    end

    private_class_method :ensure_ui_interactive
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
fastlane-2.158.0 match/lib/match/change_password.rb
fastlane-2.157.4 match/lib/match/change_password.rb
fastlane-2.157.3 match/lib/match/change_password.rb
fastlane-2.157.2 match/lib/match/change_password.rb
fastlane-2.157.1 match/lib/match/change_password.rb
fastlane-2.157.0 match/lib/match/change_password.rb
fastlane-2.156.1 match/lib/match/change_password.rb
fastlane-2.156.0 match/lib/match/change_password.rb
fastlane-2.155.3 match/lib/match/change_password.rb
fastlane-2.155.2 match/lib/match/change_password.rb
fastlane-2.155.1 match/lib/match/change_password.rb
fastlane-2.155.0 match/lib/match/change_password.rb
fastlane-2.154.0 match/lib/match/change_password.rb
fastlane-2.153.1 match/lib/match/change_password.rb
fastlane-2.153.0 match/lib/match/change_password.rb
fastlane-2.152.0 match/lib/match/change_password.rb
fastlane-2.151.2 match/lib/match/change_password.rb
fastlane-2.151.1 match/lib/match/change_password.rb
fastlane-2.151.0 match/lib/match/change_password.rb
fastlane-2.150.3 match/lib/match/change_password.rb