if node.chef_environment == "QA" branch_name = "staging" else branch_name = "master" end git "/home/user/deployment" do repository " :gitsite/deployment.git" revision branch_name action :sync user "user" group "test" end
==> default: [2015-03-17T00:09:53+00:00] ERROR: Converge failed with error message git[/home/work/apps/project] (work::project line 19) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
==> default: ---- Begin output of git branch -f master 6c97fdd97a814dc5db5523322d9b4b90196645bf ----
==> default: STDOUT:
==> default: STDERR: fatal: Cannot force update the current branch.
On Monday, March 16, 2015 at 5:49 AM, Jeff Byrnes wrote:
> Tony,
>
> This is the default behavior for the git resource. If you take a look at the docs, you’ll see the checkout_branch attribute, whose description reads: “Use to specify the name of a branch to be checked out. Default value: deploy.”
>
> So, instead of using the revision attribute, you may, instead, want to specify the checkout_branch attribute.
>
> What is happening right now is that it’s checking out a branch called deploy from the revision you’ve set, but that’s a bit confusing, based on what you’re expecting to see.
>
> -- Jeff Byrnes
Jeff is correct. The deploy resource does this because you may check out tags or pull from branches in a way that would normally cause a git error, for example if you force pushed to a branch. If you’re just pulling a git repo to a server, you don’t need to care about the deploy branch, since it will be forcibly set to the correct git rev based on the reference you specified (which you can verify for yourself with git log and git rev-parse and git ls-remote).
The checkout_branch feature is useful if you’e setting up developer laptops and you want to fetch all your git repos to a standard location and leave them on master.
--
Daniel DeLeo
Archive powered by MHonArc 2.6.16.