Permalink
Browse files

preventing 'Could not initialize herogit: undefined method `get_crede…

…ntials' for class `Heroku::Command::Auth''
  • Loading branch information...
eval committed May 5, 2011
1 parent 5cf7b14 commit a09f37bc964bf6abd719ef5fc7eb2de8e74565d5
Showing with 22 additions and 9 deletions.
  1. +22 −9 init.rb
View
31 init.rb
@@ -10,18 +10,31 @@ def herogit
@herogit
end
-class Heroku::Command::Auth
- def get_credentials_with_git
- if File.directory? ".git"
- creds = herogit.values_at("heroku.email", "heroku.password").compact
- @credentials = creds if 2 == creds.size
- end
+module Herogit
+ module Auth
+ def get_credentials_with_git
+ if File.directory? ".git"
+ creds = herogit.values_at("heroku.email", "heroku.password").compact
+ @credentials = creds if 2 == creds.size
+ end
- get_credentials_without_git
+ get_credentials_without_git
+ end
end
- alias_method :get_credentials_without_git, :get_credentials
- alias_method :get_credentials, :get_credentials_with_git
+ if defined? Heroku::Auth # heroku > v2.0
+ Heroku::Auth.extend(Herogit::Auth)
+ class << Heroku::Auth
+ alias_method :get_credentials_without_git, :get_credentials
+ alias_method :get_credentials, :get_credentials_with_git
+ end
+ else
+ Heroku::Command::Auth.class_eval do
+ include Herogit::Auth
+ alias_method :get_credentials_without_git, :get_credentials
+ alias_method :get_credentials, :get_credentials_with_git
+ end
+ end
end
class Heroku::Command::Base

0 comments on commit a09f37b

Please sign in to comment.