class DGD::Manifest::GitRepo
This is a Git repo managed by dgd-tools. It can be a source for a GoodsSpec
Attributes
git_url[R]
local_dir[R]
Public Class Methods
new(repo, git_url)
click to toggle source
# File lib/dgd-tools/manifest.rb, line 207 def initialize(repo, git_url) @git_url = git_url @repo = repo local_path = git_url.tr("/\\ ", "_") @local_dir = "#{@repo.shared_dir}/git/#{local_path}" if File.directory?(@local_dir) Dir.chdir(@local_dir) do DGD::Manifest.system_call("git checkout #{default_branch} && git pull") end else DGD::Manifest.system_call("git clone #{@git_url} #{@local_dir}") end end
Public Instance Methods
default_branch()
click to toggle source
# File lib/dgd-tools/manifest.rb, line 222 def default_branch @default_branch ||= `git rev-parse --abbrev-ref origin/HEAD`.chomp.gsub(/^origin\//, "") end
use_details(details)
click to toggle source
# File lib/dgd-tools/manifest.rb, line 226 def use_details(details) if details["branch"] Dir.chdir(@local_dir) do DGD::Manifest.system_call("git checkout #{details["branch"]} && git pull") end else Dir.chdir(@local_dir) do DGD::Manifest.system_call("git checkout #{default_branch} && git pull") end end end