Class: Match::ChangePassword

Inherits:
Object
  • Object
show all
Defined in:
lib/match/change_password.rb

Class Method Summary collapse

Class Method Details

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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/match/change_password.rb', line 15

def self.ask_password(message: "Passphrase for Git Repo: ", confirm: true)
  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

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



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/match/change_password.rb', line 3

def self.update(params: nil, from: nil, to: nil)
  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