diff options
author | Gomes da Silva <renanvice@gmail.com> | 2015-08-12 10:42:55 +0100 |
---|---|---|
committer | Gomes da Silva <renanvice@gmail.com> | 2015-08-12 10:42:55 +0100 |
commit | 87d10c0e74b850086d11d68ccb908d0aaee1ce4a (patch) | |
tree | ca0706ed969d1221ab7a5f5daa6364e864a0b5a7 | |
parent | 2999d552880ff8fe2d056f89205114ab7c3c9979 (diff) | |
download | chef-87d10c0e74b850086d11d68ccb908d0aaee1ce4a.tar.gz |
Add support for override depth and adding test in overriding depth
-rw-r--r-- | lib/chef/resource/deploy.rb | 10 | ||||
-rw-r--r-- | spec/unit/resource/deploy_spec.rb | 8 |
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 |