Sha256: 7998965adfe4cc120cfa341040d3b70a8eb58b9c0a20797041997eabc0e8c695

Contents?: true

Size: 1.42 KB

Versions: 65

Compression:

Stored size: 1.42 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])
      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("Passhprases 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

65 entries across 65 versions & 1 rubygems

Version Path
fastlane-2.24.0.beta.20170325010032 match/lib/match/change_password.rb
fastlane-2.23.0 match/lib/match/change_password.rb
fastlane-2.23.0.beta.20170322010036 match/lib/match/change_password.rb
fastlane-2.22.0 match/lib/match/change_password.rb
fastlane-2.22.0.beta.20170321010023 match/lib/match/change_password.rb
fastlane-2.21.0 match/lib/match/change_password.rb
fastlane-2.21.0.beta.20170320010043 match/lib/match/change_password.rb
fastlane-2.21.0.beta.20170319010027 match/lib/match/change_password.rb
fastlane-2.21.0.beta.20170318010107 match/lib/match/change_password.rb
fastlane-2.21.0.beta.20170317010039 match/lib/match/change_password.rb
fastlane-2.21.0.beta.20170316010039 match/lib/match/change_password.rb
fastlane-2.20.0 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170315010053 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170314010029 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170313010048 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170312010035 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170311010030 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170310010058 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170309010049 match/lib/match/change_password.rb
fastlane-2.20.0.beta.20170308010036 match/lib/match/change_password.rb