summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <mcquin@users.noreply.github.com>2014-08-08 08:35:49 -0700
committerClaire McQuin <mcquin@users.noreply.github.com>2014-08-08 08:35:49 -0700
commit35410aba1c197c72664a3aa693e4d0f586872988 (patch)
treeab1cd57ac4f37b24bbdaece6cb7740c7a24fbe75
parentb87ab7dffaad5390d8b413deacfff8baed06990d (diff)
parent4e2bc4c16254e05ffb82b1fff65354b607125b42 (diff)
downloadchef-35410aba1c197c72664a3aa693e4d0f586872988.tar.gz
Merge pull request #1694 from jordane/jordane/git_branch_B
git provider fails on existing branch names
-rw-r--r--lib/chef/provider/git.rb2
-rw-r--r--spec/unit/provider/git_spec.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index 263014d229..525249a726 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 checkout -B #{@new_resource.checkout_branch} #{sha_ref}", 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 2179db15ff..ec1e0927b8 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -224,8 +224,8 @@ SHAS
@provider.clone
end
- it "runs a checkout command with default options" do
- expected_cmd = 'git checkout -b deploy d35af14d41ae22b19da05d7d03a0bafc321b244c'
+ it "runs a checkout command with default options and uses -B to reset branches if necessary" do
+ expected_cmd = 'git checkout -B deploy d35af14d41ae22b19da05d7d03a0bafc321b244c'
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]")
@provider.checkout