Class: Braid::Operations::GitCache

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

Instance Method Summary collapse

Instance Method Details

#fetch(url) ⇒ Object



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/braid/operations.rb', line 341

def fetch(url)
  dir = path(url)

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

  if File.exists?(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



359
360
361
# File 'lib/braid/operations.rb', line 359

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