class Git::Duet::CommitCommand

Constants

DUET_ENV_VARS
SOLO_ENV_VARS

Public Class Methods

new(passthrough_argv, quiet = false) click to toggle source
# File lib/git/duet/commit_command.rb, line 10
def initialize(passthrough_argv, quiet = false)
  @passthrough_argv = passthrough_argv
  @quiet = quiet
end

Public Instance Methods

execute!() click to toggle source
# File lib/git/duet/commit_command.rb, line 15
def execute!
  in_repo_root do
    add_env_vars_to_env
    exec_git_commit
  end
end

Private Instance Methods

add_env_vars_to_env() click to toggle source
# File lib/git/duet/commit_command.rb, line 24
def add_env_vars_to_env
  extract_env_vars_from_git_config.each do |k, v|
    ENV[k] = v
  end
end
env_var_names() click to toggle source
# File lib/git/duet/commit_command.rb, line 62
def env_var_names
  return SOLO_ENV_VARS if soloing?
  DUET_ENV_VARS
end
env_var_pairs() click to toggle source
# File lib/git/duet/commit_command.rb, line 34
def env_var_pairs
  env_var_names.map do |env_var|
    [env_var, env_var.downcase.gsub(/_/, '-')]
  end
end
env_vars() click to toggle source
# File lib/git/duet/commit_command.rb, line 30
def env_vars
  @env_vars ||= Hash[env_var_pairs]
end
quoted_passthrough_args() click to toggle source
# File lib/git/duet/commit_command.rb, line 40
def quoted_passthrough_args
  @passthrough_argv.map do |arg|
    "'#{arg}'"
  end.join(' ')
end
signoff_arg() click to toggle source
# File lib/git/duet/commit_command.rb, line 46
def signoff_arg
  soloing? ? '' : '--signoff '
end
soloing?() click to toggle source
# File lib/git/duet/commit_command.rb, line 67
def soloing?
  @soloing ||=
    begin
      with_output_quieted do
        exec_check(
          "git config #{Git::Duet::Config.namespace}.git-committer-name"
        ).chomp
      end && false
    rescue StandardError
      true
    end
end