Class: Gitit::GitConfig

Inherits:
Object
  • Object
show all
Includes:
GitExecutor
Defined in:
lib/gitit/git_config.rb

Overview



Instance Attribute Summary

Attributes included from GitExecutor

#repo

Instance Method Summary collapse

Methods included from GitExecutor

#execute_command, repo

Constructor Details

#initialize(repo, location: '') ⇒ Object


Parameters:

  • repo (Object)
  • location (Object) (defaults to: '')


14
15
16
17
# File 'lib/gitit/git_config.rb', line 14

def initialize(repo, location: '')
  @repo = repo
  @location = location
end

Instance Method Details

#get_value(key) ⇒ Object


Parameters:

  • key (Object)


21
22
23
24
25
# File 'lib/gitit/git_config.rb', line 21

def get_value(key)
  value = execute_command("config #{@location} --null --get #{key}")
  raise 'failure running command' if $?.exitstatus != 0
  value.slice!(0, value.length-1)
end

#remove_section(section) ⇒ Object




44
45
46
47
# File 'lib/gitit/git_config.rb', line 44

def remove_section(section)
  execute_command("config #{@location} --remove-section #{section}")
  raise 'failure running command' if $?.exitstatus != 0
end

#set_value(key, value) ⇒ Object


Parameters:

  • key (Object)
  • value (Object)


30
31
32
33
34
# File 'lib/gitit/git_config.rb', line 30

def set_value(key, value)
  val = value
  execute_command("config #{@location} \"#{key}\" \"#{val}\"")
  raise 'failure running command' if $?.exitstatus != 0
end

#unset_value(key) ⇒ Object


Parameters:

  • key (Object)


38
39
40
41
# File 'lib/gitit/git_config.rb', line 38

def unset_value(key)
  execute_command("config #{@location} --null --unset #{key}")
  raise 'failure running command' if $?.exitstatus != 0
end