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



555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'lib/braid/operations.rb', line 555

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



574
575
576
# File 'lib/braid/operations.rb', line 574

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