class GitShallowClone

handle shallow clone by default

Attributes

git_dir[R]
options[R]
pr[R]
repo_protocol[R]

Public Class Methods

new(git_dir, pr, options) click to toggle source
# File lib/gitarro/git_op.rb, line 11
def initialize(git_dir, pr, options)
  @git_dir = git_dir
  # pr object for extract all relev. data.
  @pr = pr
  # All gitarro options
  @options = options
  gh = 'https://github.com/'
  gg = 'git@github.com:'
  @repo_protocol = @options[:https] ? gh : gg
  @repo_url = @options[:https] ? pr.head.repo.html_url : pr.head.repo.ssh_url
end

Public Instance Methods

clone() click to toggle source

shallow clone

# File lib/gitarro/git_op.rb, line 24
def clone
  tmp_dir = create_tmp_dir!
  git_local = "#{git_dir}/#{tmp_dir}"
  puts `git clone --depth 1 #{@repo_url} -b #{pr.head.ref} #{git_local}`
  exit 1 if $CHILD_STATUS.exitstatus.nonzero?
  Dir.chdir git_local
end

Private Instance Methods

create_tmp_dir!() click to toggle source
# File lib/gitarro/git_op.rb, line 34
def create_tmp_dir!
  repo = options[:repo].split('/')[1]
  "#{repo}#{Time.now.to_i}_#{rand(100)}"
end