summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Goulah <jgoulah@gmail.com>2012-12-28 16:15:34 -0500
committerBryan McLellan <btm@opscode.com>2013-11-26 07:31:19 -0800
commit376177d9d3ebb0a239ea5a43fd64b2b74f38b361 (patch)
tree80d6f3d2cfddb5778c4b337450d4d05cc22a98b5
parentce6135e76f1be4e1496a052188183e63332ea7dc (diff)
downloadchef-376177d9d3ebb0a239ea5a43fd64b2b74f38b361.tar.gz
add enable_checkout attribute; add ability to override 'deploy' with checkout_branch name
-rw-r--r--lib/chef/provider/git.rb11
-rw-r--r--lib/chef/resource/scm.rb18
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index b22004eda0..ac128b7d2f 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -151,10 +151,13 @@ class Chef
def checkout
sha_ref = target_revision
- 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 deploy #{sha_ref}", run_options(:cwd => @new_resource.destination))
- Chef::Log.info "#{@new_resource} checked out branch: #{@new_resource.revision} reference: #{sha_ref}"
+
+ if @new_resource.enable_checkout
+ 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))
+ Chef::Log.info "#{@new_resource} checked out branch: #{@new_resource.revision} onto: #{@new_resource.checkout_branch} reference: #{sha_ref}"
+ end
end
end
diff --git a/lib/chef/resource/scm.rb b/lib/chef/resource/scm.rb
index d9a372900e..91782e4114 100644
--- a/lib/chef/resource/scm.rb
+++ b/lib/chef/resource/scm.rb
@@ -32,12 +32,14 @@ class Chef
@destination = name
@resource_name = :scm
@enable_submodules = false
+ @enable_checkout = true
@revision = "HEAD"
@remote = "origin"
@ssh_wrapper = nil
@depth = nil
@allowed_actions.push(:checkout, :export, :sync, :diff, :log)
@action = [:sync]
+ @checkout_branch = "deploy"
end
def destination(arg=nil)
@@ -130,6 +132,14 @@ class Chef
)
end
+ def enable_checkout(arg=nil)
+ set_or_return(
+ :enable_checkout,
+ arg,
+ :kind_of => [TrueClass, FalseClass]
+ )
+ end
+
def remote(arg=nil)
set_or_return(
:remote,
@@ -154,6 +164,14 @@ class Chef
)
end
+ def checkout_branch(arg=nil)
+ set_or_return(
+ :checkout_branch,
+ arg,
+ :kind_of => String
+ )
+ end
+
end
end
end