summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-08-13 14:58:07 +0100
committerThom May <thom@may.lt>2015-08-13 14:58:07 +0100
commit4c0c2dbef1c5f52bb93c849fa40b8988d73a4970 (patch)
tree2ec1394b0d18832b1723d0829886f9f14d9cf6a3
parentd9d63aa96bb0003c4d1e84e79ef86e2778ce21c9 (diff)
parent87d10c0e74b850086d11d68ccb908d0aaee1ce4a (diff)
downloadchef-4c0c2dbef1c5f52bb93c849fa40b8988d73a4970.tar.gz
Merge pull request #3771 from renanvicente/renanvicente/add-specify-depth
Add support for override depth and adding test in overriding depth
-rw-r--r--lib/chef/resource/deploy.rb10
-rw-r--r--spec/unit/resource/deploy_spec.rb8
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/chef/resource/deploy.rb b/lib/chef/resource/deploy.rb
index 3e5255bced..5df46fff60 100644
--- a/lib/chef/resource/deploy.rb
+++ b/lib/chef/resource/deploy.rb
@@ -27,6 +27,7 @@
# migration_command "rake db:migrate"
# environment "RAILS_ENV" => "production", "OTHER_ENV" => "foo"
# shallow_clone true
+# depth 1
# action :deploy # or :rollback
# restart_command "touch tmp/restart.txt"
# git_ssh_wrapper "wrap-ssh4git.sh"
@@ -74,6 +75,7 @@ class Chef
@remote = "origin"
@enable_submodules = false
@shallow_clone = false
+ @depth = nil
@scm_provider = Chef::Provider::Git
@svn_force_export = false
@additional_remotes = Hash[]
@@ -97,8 +99,12 @@ class Chef
@current_path ||= @deploy_to + "/current"
end
- def depth
- @shallow_clone ? "5" : nil
+ def depth(arg=@shallow_clone ? 5 : nil)
+ set_or_return(
+ :depth,
+ arg,
+ :kind_of => [ Integer ]
+ )
end
# note: deploy_to is your application "meta-root."
diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb
index 0403a7ba6b..5b6a452784 100644
--- a/spec/unit/resource/deploy_spec.rb
+++ b/spec/unit/resource/deploy_spec.rb
@@ -148,10 +148,16 @@ describe Chef::Resource::Deploy do
expect(@resource.current_path).to eql("/my/deploy/dir/current")
end
+ it "allows depth to be set via integer" do
+ expect(@resource.depth).to be_nil
+ @resource.depth 1
+ expect(@resource.depth).to eql(1)
+ end
+
it "gives #depth as 5 if shallow clone is true, nil otherwise" do
expect(@resource.depth).to be_nil
@resource.shallow_clone true
- expect(@resource.depth).to eql("5")
+ expect(@resource.depth).to eql(5)
end
it "aliases repo as repository" do