Git branch questions

Ohai,

I am using the following to check out code:

git ‘/opt/test’ do
repository 'git://github.com/Production/test.git’
branch 'production’
action :sync
user ‘test’
end

this results in this:

[root@testbox test]# git branch

  • deploy
    staging

this command:

git clone -b production git://github.com/Production/test.git test2
[root@testbox test2]# git branch

  • production

This is causing concern because the devs aren’t 100% sure if this the production branch or not. Is this normal? Did I miss something? Am I doing something wrong? I tried checkout_branch and get this:

undefined method `checkout_branch’ for Chef::Resource::Git

Any help would be appreciated.

Jenn:

You’ll actually want to use something like this:

git ‘/opt/test’ do
repository 'git://github.com/Production/test.git’
revision 'production’
action :sync
user 'test’
end
or this:

git ‘/opt/test’ do
repository 'git://github.com/Production/test.git’
checkout_branch 'production’
action :sync
user 'test’
end
There’s no branch attribute, so you’re ending up with the default value for the checkout_branch attribute, which is deploy.

See the docs for the git resource’s attributes for more details.


Jeff Byrnes
@berkleebassist
Operations Engineer
EverTrue
704.516.4628

On April 11, 2014 at 10:54:22 AM, Jenn Fountain (jfountain@meetme.com) wrote:

Ohai,

I am using the following to check out code:

git ‘/opt/test’ do
repository 'git://github.com/Production/test.git’
branch 'production’
action :sync
user ‘test’
end

this results in this:

[root@testbox test]# git branch

  • deploy
    staging

this command:

git clone -b production git://github.com/Production/test.git test2
[root@testbox test2]# git branch

  • production

This is causing concern because the devs aren’t 100% sure if this the production branch or not. Is this normal? Did I miss something? Am I doing something wrong? I tried checkout_branch and get this:

undefined method `checkout_branch’ for Chef::Resource::Git

Any help would be appreciated.

Actually, Jenn was on the right track. See the ticket here which has some discussion about the use case and usage: https://tickets.opscode.com/browse/CHEF-3734

Jenn, I think you’re probably on too old a version of Chef to use this feature. You need at least 11.10. I think you also need to add enable_checkout false to your git resource to have it use the default branch from the upstream.

--
Daniel DeLeo

On Friday, April 11, 2014 at 8:02 AM, Jeff Byrnes wrote:

Jenn:
You’ll actually want to use something like this:
git '/opt/test' do repository 'git://github.com/Production/test.git' (http://github.com/Production/test.git') revision 'production' action :sync user 'test' end
or this:
git '/opt/test' do repository 'git://github.com/Production/test.git' (http://github.com/Production/test.git') checkout_branch 'production' action :sync user 'test' end
There’s no branch attribute, so you’re ending up with the default value for the checkout_branch attribute, which is deploy.
See the docs for the git resource’s attributes for more details.

-- Jeff Byrnes
@berkleebassist (http://twitter.com/berkleebassist)
Operations Engineer
EverTrue (http://www.evertrue.com/)
704.516.4628

On April 11, 2014 at 10:54:22 AM, Jenn Fountain (jfountain@meetme.com (mailto:jfountain@meetme.com)) wrote:

Ohai,

I am using the following to check out code:

git '/opt/test' do
repository 'git://github.com/Production/test.git' (http://github.com/Production/test.git')
branch 'production'
action :sync
user ‘test'
end

this results in this:

[root@testbox test]# git branch

  • deploy
    staging

this command:

git clone -b production git://github.com/Production/test.git (http://github.com/Production/test.git) test2
[root@testbox test2]# git branch

  • production

This is causing concern because the devs aren’t 100% sure if this the production branch or not. Is this normal? Did I miss something? Am I doing something wrong? I tried checkout_branch and get this:

undefined method `checkout_branch' for Chef::Resource::Git

Any help would be appreciated.

Ah, that was it. We are using an older version.

Now to see why Cobbler is pulling down the older version. Thanks!!

On Apr 11, 2014, at 11:09 AM, Daniel DeLeo dan@kallistec.com wrote:

Actually, Jenn was on the right track. See the ticket here which has some discussion about the use case and usage: https://tickets.opscode.com/browse/CHEF-3734

Jenn, I think you’re probably on too old a version of Chef to use this feature. You need at least 11.10. I think you also need to add enable_checkout false to your git resource to have it use the default branch from the upstream.

--
Daniel DeLeo

On Friday, April 11, 2014 at 8:02 AM, Jeff Byrnes wrote:

Jenn:
You’ll actually want to use something like this:
git '/opt/test' do repository 'git://github.com/Production/test.git' (http://github.com/Production/test.git') revision 'production' action :sync user 'test' end
or this:
git '/opt/test' do repository 'git://github.com/Production/test.git' (http://github.com/Production/test.git') checkout_branch 'production' action :sync user 'test' end
There’s no branch attribute, so you’re ending up with the default value for the checkout_branch attribute, which is deploy.
See the docs for the git resource’s attributes for more details.

-- Jeff Byrnes
@berkleebassist (http://twitter.com/berkleebassist)
Operations Engineer
EverTrue (http://www.evertrue.com/)
704.516.4628

On April 11, 2014 at 10:54:22 AM, Jenn Fountain (jfountain@meetme.com (mailto:jfountain@meetme.com)) wrote:

Ohai,

I am using the following to check out code:

git '/opt/test' do
repository 'git://github.com/Production/test.git' (http://github.com/Production/test.git')
branch 'production'
action :sync
user ‘test'
end

this results in this:

[root@testbox test]# git branch

  • deploy
    staging

this command:

git clone -b production git://github.com/Production/test.git (http://github.com/Production/test.git) test2
[root@testbox test2]# git branch

  • production

This is causing concern because the devs aren’t 100% sure if this the production branch or not. Is this normal? Did I miss something? Am I doing something wrong? I tried checkout_branch and get this:

undefined method `checkout_branch' for Chef::Resource::Git

Any help would be appreciated.