Class: RailGrinder::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/rail_grinder/repository.rb

Overview

Represent a git repository. Handle cloning a repo into a project, and once it’s there, performing commits and pushes.

Instance Method Summary collapse

Constructor Details

#initialize(url, repo_dir) ⇒ Repository

Returns a new instance of Repository.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rail_grinder/repository.rb', line 20

def initialize(url, repo_dir)
  unless url
    raise "Please provide the url to a git repository.\n eg. $ rg.rb add [email protected]:lycoperdon/foo.git"
  end
  @url = url
  @path = "#{repo_dir}/#{RailGrinder.inferred_name(@url)}"

  system "git clone #{@url} #{@path}"
  # Make sure the clone call went Ok
  if $CHILD_STATUS.signaled?
    puts "!! child died with signal %d, %s coredump" % [$CHILD_STATUS.termsig, $CHILD_STATUS.coredump? ? 'with' : 'without']
  elsif $CHILD_STATUS.exitstatus != 0
    puts "!! child exited with value %d\n" % [$CHILD_STATUS.exitstatus]
  end
end