Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 43 lines (37 sloc) 1.339 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
Chef::Log.warn 'Please use https://github.com/pivotal-sprout/sprout instead'

# Recipe to clone git repositories into the users workspace_directory
#
# Repositories should be defined as an array in the node_attributes section of
# your `soloistrc` file. eg:
#
# node_attributes:
# git_projects:
# -
# - repository-name (folder to be checked out into within your workspace folder)
# - repository-url (source url)
# -
# - rails
# - git@github.com:rails/rails.git
# -
# - hubot
# - git@github.com:github/hubot.git
#

include_recipe "pivotal_workstation::workspace_directory"

node['git_projects'].each do |repo_name, repo_address, repo_dir|

  # Allow the user to override the working directory
  repo_dir ||= node['workspace_directory']

  execute "clone #{repo_name}" do
    command "git clone #{repo_address} #{repo_name}"
    user WS_USER
    cwd "#{WS_HOME}/#{repo_dir}/"
    not_if { ::File.exists?("#{WS_HOME}/#{repo_dir}/#{repo_name}") }
  end

  [ "git branch --set-upstream master origin/master", "git submodule update --init --recursive" ].each do |git_cmd|
    execute "#{repo_name} - #{git_cmd}" do
      command git_cmd
      cwd "#{WS_HOME}/#{repo_dir}/#{repo_name}"
      user WS_USER
      not_if { ::File.exists?("#{WS_HOME}/#{repo_dir}/#{repo_name}") }
    end
  end
end
Something went wrong with that request. Please try again.