Class: JumanjimanSpecHelper::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/jumanjiman_spec_helper/git.rb

Class Method Summary collapse

Class Method Details

.config_data(path) ⇒ Object



15
16
17
# File 'lib/jumanjiman_spec_helper/git.rb', line 15

def self.config_data(path)
  IniFile.new(:filename => path).read
end

.git_config_pathObject



19
20
21
# File 'lib/jumanjiman_spec_helper/git.rb', line 19

def self.git_config_path
  File.join(repo_root, '.git', 'config')
end

.repo_config_pathObject



23
24
25
# File 'lib/jumanjiman_spec_helper/git.rb', line 23

def self.repo_config_path
  File.join(repo_root, '.repo', 'config')
end

.repo_rootObject



10
11
12
13
# File 'lib/jumanjiman_spec_helper/git.rb', line 10

def self.repo_root
  ENV['GIT_PAGER'] = '' # https://github.com/3ofcoins/minigit#issues
  repo_root ||= MiniGit.new(Dir.pwd).git_work_tree
end

.update_git_configObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jumanjiman_spec_helper/git.rb', line 27

def self.update_git_config
  repo_data = config_data(repo_config_path)
  if repo_data
    git_data = config_data(git_config_path)
    repo_data.each do |sect, param, val|
      git_data[sect][param] = val.gsub(/REPO_ROOT/, repo_root)
    end
    i = IniFile.new(:filename => git_config_path).read.merge(git_data)
    i.save
  end
end