# vim: ft=ruby:sts=2:expandtab # – OVERRIDES

set :git_recursive_submodules, 0 namespace :git do

desc 'Copy repo to releases'
task create_release: :'git:update' do
  on roles(:all) do
    with fetch(:git_environmental_variables) do
      within repo_path do
        if(fetch(:git_recursive_submodules))
          execute :git, :clone, '-b', fetch(:branch), '--recursive', '.', release_path
        else
          execute :git, :clone, '-b', fetch(:branch), '.', release_path
        end
      end
    end
  end
end

desc "remove remote git cache repository"
task :remove_git_cache_repo do
  on roles(:all) do
    execute "cd #{fetch(:deploy_to)} && rm -Rf repo"
  end
end

task "check_branch" do
  current_branch = `git branch | grep \\* | cut -d ' ' -f2`.strip
  if current_branch != fetch(:branch)
    raise "current branch differs from homestead.rb configuration.\n see config/deploy/homestead.rb\n\n Current branch:   #{current_branch}\n Homestead branch: #{fetch(:branch)} "
  end
end

end