Sha256: f7cb0f3695801db67be0d37d342b7c25110b04eb28e3819d982308c83c0fe3a5

Contents?: true

Size: 1.78 KB

Versions: 315

Compression:

Stored size: 1.78 KB

Contents

module Match
  # These functions should only be used while in (UI.) interactive mode
  class ChangePassword
    def self.update(params: nil, from: nil, to: nil)
      ensure_ui_interactive
      to ||= ChangePassword.ask_password(message: "New passphrase for Git Repo: ", confirm: false)
      from ||= ChangePassword.ask_password(message: "Old passphrase for Git Repo: ", confirm: true)
      GitHelper.clear_changes
      workspace = GitHelper.clone(params[:git_url],
                                  params[:shallow_clone],
                                  manual_password: from,
                                  skip_docs: params[:skip_docs],
                                  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])
      Encrypt.new.clear_password(params[:git_url])
      Encrypt.new.store_password(params[:git_url], to)

      message = "[fastlane] Changed passphrase"
      GitHelper.commit_changes(workspace, message, params[:git_url], params[:git_branch])
    end

    def self.ask_password(message: "Passphrase for Git Repo: ", confirm: true)
      ensure_ui_interactive
      loop do
        password = UI.password(message)
        if confirm
          password2 = UI.password("Type passphrase again: ")
          if password == password2
            return password
          end
        else
          return password
        end
        UI.error("Passphrases differ. Try again")
      end
    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

315 entries across 315 versions & 1 rubygems

Version Path
fastlane-2.74.0.beta.20180106010004 match/lib/match/change_password.rb
fastlane-2.73.0 match/lib/match/change_password.rb
fastlane-2.73.0.beta.20180105010003 match/lib/match/change_password.rb
fastlane-2.73.0.beta.20180104010004 match/lib/match/change_password.rb
fastlane-2.73.0.beta.20180103010003 match/lib/match/change_password.rb
fastlane-2.72.0 match/lib/match/change_password.rb
fastlane-2.72.0.beta.20180102010003 match/lib/match/change_password.rb
fastlane-2.72.0.beta.20180101010003 match/lib/match/change_password.rb
fastlane-2.72.0.beta.20171231010003 match/lib/match/change_password.rb
fastlane-2.71.1 match/lib/match/change_password.rb
fastlane-2.72.0.beta.20171230010003 match/lib/match/change_password.rb
fastlane-2.72.0.beta.20171229010003 match/lib/match/change_password.rb
fastlane-2.72.0.beta.20171228010004 match/lib/match/change_password.rb
fastlane-2.71.0 match/lib/match/change_password.rb
fastlane-2.71.0.beta.20171227010004 match/lib/match/change_password.rb
fastlane-2.71.0.beta.20171226010004 match/lib/match/change_password.rb
fastlane-2.71.0.beta.20171225010003 match/lib/match/change_password.rb
fastlane-2.71.0.beta.20171224010003 match/lib/match/change_password.rb
fastlane-2.71.0.beta.20171223010003 match/lib/match/change_password.rb
fastlane-2.71.0.beta.20171222010003 match/lib/match/change_password.rb