class DidGood::GitRepo
This is a DidGood-downloaded Git repo. 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/didgood.rb, line 131 def initialize(repo, git_url) @git_url = git_url @repo = repo local_path = git_url.tr("/\\", "_") @local_dir = "#{@repo.didgood_dir}/git/#{local_path}" if File.directory?(@local_dir) Dir.chdir(@local_dir) do DidGood.system_call("git checkout #{default_branch} && git pull") end else DidGood.system_call("git clone #{@git_url} #{@local_dir}") end end
Public Instance Methods
default_branch()
click to toggle source
# File lib/didgood.rb, line 146 def default_branch return @default_branch if @default_branch output = `git rev-parse --abbrev-ref origin/HEAD`.chomp @default_branch = output.gsub(/^origin\//, "") end
use_details(details)
click to toggle source
# File lib/didgood.rb, line 152 def use_details(details) if details["branch"] Dir.chdir(@local_dir) do DidGood.system_call("git checkout #{details["branch"]}") end else Dir.chdir(@local_dir) do DidGood.system_call("git checkout #{default_branch}") end end end