Module: Gas::GitConfig

Defined in:
lib/gas/git_config.rb

Overview

Module that class that interacts with the git config

Class Method Summary collapse

Class Method Details

.change_user(user) ⇒ Object

Changes the user

Parameters:



20
21
22
23
# File 'lib/gas/git_config.rb', line 20

def self.change_user(user)
  `git config --global user.name "#{user.name}"`
  `git config --global user.email "#{user.email}"`
end

.current_userGas::User

Parse out the current user from the gitconfig

Parameters:

  • gitconfig (String)

    The git configuration

Returns:

  • (Gas::User)

    The current user or nil if not present



9
10
11
12
13
14
15
16
# File 'lib/gas/git_config.rb', line 9

def self.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")   # git cli returns the name and email with \n at the end
end