-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathauth.rb
39 lines (29 loc) · 890 Bytes
/
auth.rb
1
2
3
4
5
6
7
8
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
module Heroku
class Auth
def self.user
fetch_from_account[:username]
end
def self.password
fetch_from_account[:password]
end
private ####################################################################
def self.extract_account
@account ||= begin
account = Heroku::Command.current_options[:account] rescue nil
unless account
account = ENV["HEROKU_ACCOUNT"] || %x{ git config heroku.account }.chomp
end
raise(Heroku::Command::CommandFailed, <<-ERROR) if account.to_s.strip == ''
No account specified.
Run this command with --account <account name>
You can also add it as a git config attribute with:
git config heroku.account work
ERROR
account
end
end
def self.fetch_from_account
account = Heroku::Command::Accounts.account(extract_account)
end
end
end