Method: TestIds::Git#initialize

Defined in:
lib/test_ids/git.rb

#initialize(options) ⇒ Git

Returns a new instance of Git.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/test_ids/git.rb', line 52

def initialize(options)
  unless File.exist?("#{options[:local]}/.git")
    FileUtils.rm_rf(options[:local]) if File.exist?(options[:local])
    FileUtils.mkdir_p(options[:local])
    Dir.chdir options[:local] do
      `git clone #{options[:remote]} .`
      unless File.exist?('lock.json')
        # Should really try to use the Git driver for this
        exec 'touch lock.json'
        exec 'git add lock.json'
        exec 'git commit -m "Initial commit"'
        exec 'git push'
      end
    end
  end
  @local = options[:local]
  @repo = ::Git.open(options[:local])
  # Get rid of any local edits coming in here, this is only called once at the start
  # of the program generation run.
  # No need to pull latest as that will be done when we obtain a lock.
  @repo.reset_hard
end