Skip to content

Commit

Permalink
Handle remote change in git_clone macro
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet committed May 4, 2015
1 parent d76ba19 commit 6a1f8e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cookbooks/git/definitions/git_clone.rb
Expand Up @@ -42,6 +42,11 @@

env_for_not_if = use_proxy ? get_proxy_environment : {}

execute "check remote for #{git_clone_params[:name]}" do
command "cd #{git_clone_params[:name]} && git remote rm origin && git remote add origin #{git_clone_params[:repository]}"
not_if "cd #{git_clone_params[:name]} && git remote -v | grep origin | grep #{git_clone_params[:repository]}"
end

execute "update git clone of #{git_clone_params[:repository]} to #{git_clone_params[:name]}" do
user git_clone_params[:user]
command "cd #{git_clone_params[:name]} && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard #{sha} && git clean #{clean_options} && git log -n1 --decorate | head -n 1 | grep #{sha}"
Expand Down

0 comments on commit 6a1f8e2

Please sign in to comment.