Method: Git#checkout

Defined in:
lib/version_control/git.rb

#checkout(init = false, options = {}) ⇒ Object

Performs a GIT checkout or initialize repository

Attributes

  • init - true to initilize the checkout and local repo

  • options - hash of options, keys [repository, branch, revision, tag]

Returns

  • command output



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/version_control/git.rb', line 68

def checkout(init = false, options = {})
  update_repo_info(options)
  if init
    cmd = "#{@git} clone #{@url} #{@credential}"
    process_cmd(cmd)
    cmd = "#{@git} checkout #{@branch}"
  else
    revision = get_option(options,"revision")
    tag = get_option(options,"tag")
    if revision != ""
      cmd = "#{@git} checkout #{revision}"
    elsif tag != ""
      cmd = "#{@git} checkout tags/#{tag}"
    else
      cmd = "#{@git} pull #{@repo} #{@branch}"
    end
  end
  process_cmd(cmd)
end