class Git::Duet::DuetCommand

Attributes

alpha[RW]
author_mapper[RW]
omega[RW]

Public Class Methods

new(alpha, omega, quiet = false, global = false) click to toggle source
# File lib/git/duet/duet_command.rb, line 11
def initialize(alpha, omega, quiet = false, global = false)
  @alpha = alpha
  @omega = omega
  @quiet = !!quiet
  @global = !!global
  @author_mapper = Git::Duet::AuthorMapper.new
end

Public Instance Methods

execute!() click to toggle source
# File lib/git/duet/duet_command.rb, line 19
def execute!
  if alpha && omega
    set_alpha_as_git_config_user
    report_env_vars
    write_env_vars
  else
    show_current_config
  end
end

Private Instance Methods

alpha_info() click to toggle source
# File lib/git/duet/duet_command.rb, line 50
def alpha_info
  fetch_info(alpha, 'author')
end
alpha_omega_info() click to toggle source
# File lib/git/duet/duet_command.rb, line 65
def alpha_omega_info
  @alpha_omega_info ||= author_mapper.map(alpha, omega)
end
fetch_info(which, desc) click to toggle source
# File lib/git/duet/duet_command.rb, line 58
def fetch_info(which, desc)
  alpha_omega_info.fetch(which)
rescue KeyError, IndexError => e
  error("git-duet: Failed to find #{desc}: #{e}")
  raise Git::Duet::ScriptDieError, 86
end
omega_info() click to toggle source
# File lib/git/duet/duet_command.rb, line 54
def omega_info
  fetch_info(omega, 'committer')
end
set_alpha_as_git_config_user() click to toggle source
# File lib/git/duet/duet_command.rb, line 33
def set_alpha_as_git_config_user
  %w(name email).each do |setting|
    exec_check(
      "#{git_config} user.#{setting} '#{alpha_info[setting.to_sym]}'"
    )
  end
end
var_map() click to toggle source
# File lib/git/duet/duet_command.rb, line 41
def var_map
  {
    'GIT_AUTHOR_NAME' => alpha_info[:name],
    'GIT_AUTHOR_EMAIL' => alpha_info[:email],
    'GIT_COMMITTER_NAME' => omega_info[:name],
    'GIT_COMMITTER_EMAIL' => omega_info[:email]
  }
end