Class: Fastlane::Flint::ChangePassword

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/flint/helper/change_password.rb

Overview

These functions should only be used while in (UI.) interactive mode

Class Method Summary collapse

Class Method Details

.ask_password(message: "Passphrase for Git Repo: ", confirm: true) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/flint/helper/change_password.rb', line 44

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

.update(params: nil, from: nil, to: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/flint/helper/change_password.rb', line 9

def self.update(params: nil, from: nil, to: nil)
  ensure_ui_interactive
  from ||= ChangePassword.ask_password(message: "Old passphrase for Git Repo: ", confirm: false)
  to ||= ChangePassword.ask_password(message: "New passphrase for Git Repo: ", confirm: true)
  GitHelper.clear_changes
  encrypt = Encrypt.new
  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: encrypt)
  encrypt.clear_password(params[:git_url])
  encrypt.store_password(params[:git_url], to)

  if params[:app_identifier].kind_of?(Array)
    app_identifiers = params[:app_identifier]
  else
    app_identifiers = params[:app_identifier].to_s.split(/\s*,\s*/).uniq
  end
  app_identifier = app_identifiers[0].gsub! '.', '_'

  for cert_type in Flint.environments do
    alias_name = "%s-%s" % [app_identifier, cert_type]
    keystore_name = "%s.keystore" % alias_name
    Flint::Generator.update_keystore_password(workspace, keystore_name, alias_name, from, to)
  end

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