[chef] Re: Re: Re: Strange git behavior - any suggestion is welcome


Chronological Thread 
  • From: Anthony Kong < >
  • To:
  • Subject: [chef] Re: Re: Re: Strange git behavior - any suggestion is welcome
  • Date: Tue, 17 Mar 2015 11:32:31 +1100

Hi Jeff and Daniel, 

Thanks very much for the answer!

According to an example on the resource_git page (reproduced here)

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

It seems to suggest revision can be used to specify a branch. 



Now I switched to use checkout_branch, and I get this error:

==> 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.


Is the 'sync' action not compatible to the checkout_branch?

Cheers


On Tue, Mar 17, 2015 at 3:12 AM, Daniel DeLeo < " target="_blank"> > wrote:
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.

§