Class: Gas::Gitconfig
- Inherits:
-
Object
- Object
- Gas::Gitconfig
- Defined in:
- lib/gas/gitconfig.rb
Overview
Class that class that interacts with the git config
Constant Summary collapse
- @@nickname =
''
Instance Method Summary collapse
-
#change_user(user) ⇒ Object
Changes the user.
-
#current_user ⇒ User
Parse out the current user from the gitconfig.
-
#current_user_object ⇒ Object
Get current user.
Instance Method Details
#change_user(user) ⇒ Object
Changes the user
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gas/gitconfig.rb', line 31 def change_user(user) nickname = user.nickname @@nickname = nickname # maybe we should make nickname a class variable? name = user.name email = user.email `git config --global user.name "#{name}"` `git config --global user.email "#{email}"` # confirm that this user has an ssh and if so, swap it in safely Ssh.swap_in_rsa nickname end |
#current_user ⇒ User
Parse out the current user from the gitconfig
9 10 11 12 13 14 15 16 |
# File 'lib/gas/gitconfig.rb', line 9 def current_user name = `git config --global --get user.name` email = `git config --global --get user.email` return nil if name.nil? && email.nil? User.new name.delete("\n"), email.delete("\n"), @@nickname # git cli returns the name and email with \n at the end end |
#current_user_object ⇒ Object
Get current user
19 20 21 22 23 24 25 26 |
# File 'lib/gas/gitconfig.rb', line 19 def current_user_object name = `git config --global --get user.name` email = `git config --global --get user.email` return nil if name.nil? && email.nil? return {:name => name.strip, :email => email.strip} end |