diff options
-rw-r--r-- | lib/chef/provider/git.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/git_spec.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index aa58fdc4a1..9a2e6e2291 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -150,7 +150,7 @@ class Chef converge_by("checkout ref #{sha_ref} branch #{@new_resource.revision}") do # checkout into a local branch rather than a detached HEAD - shell_out!("git checkout -B #{@new_resource.checkout_branch} #{sha_ref}", run_options(:cwd => @new_resource.destination)) + shell_out!("git branch -f #{@new_resource.checkout_branch} #{sha_ref}; git checkout #{@new_resource.checkout_branch}", run_options(:cwd => @new_resource.destination)) Chef::Log.info "#{@new_resource} checked out branch: #{@new_resource.revision} onto: #{@new_resource.checkout_branch} reference: #{sha_ref}" end end diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 143c22da6e..69a6443c67 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -244,8 +244,8 @@ SHAS @provider.clone end - it "runs a checkout command with default options and uses -B to reset branches if necessary" do - expected_cmd = 'git checkout -B deploy d35af14d41ae22b19da05d7d03a0bafc321b244c' + it "runs a checkout command with default options" do + expected_cmd = 'git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c; git checkout deploy' @provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") @provider.checkout |