Class: Braid::Operations::GitCache

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Singleton
Defined in:
lib/braid/operations.rb

Instance Method Summary collapse

Methods included from T::Sig

sig

Instance Method Details

#fetch(url) ⇒ Object



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/braid/operations.rb', line 561

def fetch(url)
  dir = path(url)

  # remove local cache if it was created with --no-checkout
  if File.exist?("#{dir}/.git")
    FileUtils.rm_r(dir)
  end

  if File.exist?(dir)
    Dir.chdir(dir) do
      git.fetch
    end
  else
    FileUtils.mkdir_p(local_cache_dir)
    git.clone(['--mirror', url, dir])
  end
end

#path(url) ⇒ Object



580
581
582
# File 'lib/braid/operations.rb', line 580

def path(url)
  File.join(local_cache_dir, url.gsub(/[\/:@]/, '_'))
end