summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/chef/provider/git.rb5
-rw-r--r--spec/unit/provider/git_spec.rb15
3 files changed, 22 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b7a2f352b..f6ac61daa7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
## Unreleased: 12.0.0
+* [**Jesse Hu**](https://github.com/jessehu):
+ retry on HTTP 50X Error when calling Chef REST API
* [**Nolan Davidson**](https://github.com/nsdavidson):
The chef-apply command now prints usage information when called without arguments
* [**Kazuki Saito**](https://github.com/sakazuki):
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index 5b785c31fc..c8e615c1f9 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -102,6 +102,10 @@ class Chef
end
end
+ def git_minor_version
+ @git_minor_version ||= Gem::Version.new(shell_out!('git --version', run_options).stdout.split.last)
+ end
+
def existing_git_clone?
::File.exist?(::File.join(@new_resource.destination, ".git"))
end
@@ -137,6 +141,7 @@ class Chef
args = []
args << "-o #{remote}" unless remote == 'origin'
args << "--depth #{@new_resource.depth}" if @new_resource.depth
+ args << "--no-single-branch" if @new_resource.depth and git_minor_version >= Gem::Version.new('1.7.10')
Chef::Log.info "#{@new_resource} cloning repo #{@new_resource.repository} to #{@new_resource.destination}"
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 20b13c4cb0..ff1c0b0398 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -233,6 +233,21 @@ SHAS
it "compiles a clone command using --depth for shallow cloning" do
@resource.depth 5
expected_cmd = "git clone --depth 5 \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\""
+ version_response = double('shell_out')
+ version_response.stub(:stdout) { 'git version 1.7.9' }
+ @provider.should_receive(:shell_out!).with("git --version",
+ :log_tag => "git[web2.0 app]").and_return(version_response)
+ @provider.should_receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ @provider.clone
+ end
+
+ it "compiles a clone command using --no-single-branch for shallow cloning when git >= 1.7.10" do
+ @resource.depth 5
+ expected_cmd = "git clone --depth 5 --no-single-branch \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\""
+ version_response = double('shell_out')
+ version_response.stub(:stdout) { 'git version 1.7.10' }
+ @provider.should_receive(:shell_out!).with("git --version",
+ :log_tag => "git[web2.0 app]").and_return(version_response)
@provider.should_receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
@provider.clone
end