poise / application_ruby

Development repository for Opscode Cookbook application_ruby
Apache License 2.0
124 stars 153 forks source link

Specify branch, tag, or revision for git clone #89

Closed daharon closed 7 years ago

daharon commented 7 years ago

I want to use the application resource in such a way that I can specify the tag to clone using Git. Like so:

application '/srv/my-app' do
  git 'https://github.com/daharon/my-app.git' do
    revision 'v1.0.0'  # A git tag.
  end

  bundle_install
  rails
  unicorn
end

The above fails, though.

How can I specify the tag or commit hash of the Git repository that I wish to clone?

coderanger commented 7 years ago

That should work fine.

daharon commented 7 years ago

This is the specific error I'm seeing:

       Recipe: role-chef::webui
         * application[/srv/chef-webui] action deploy
           * directory[/srv/chef-webui] action create (up to date)
            (up to date)
         * git[https://github.com/chef-boneyard/chef-server-webui.git] action sync

           ================================================================================
           Error executing action `sync` on resource 'git[https://github.com/chef-boneyard/chef-server-webui.git]'
           ================================================================================

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '128'
           ---- Begin output of git ls-remote "" "11.1.5*" ----
           STDOUT: 
           STDERR: fatal: No path specified. See 'man git-pull' for valid url syntax
           ---- End output of git ls-remote "" "11.1.5*" ----
           Ran git ls-remote "" "11.1.5*" returned 128

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/role-chef/recipes/webui.rb

             8:   git node['role-chef'][:webui][:url] do
             9:     revision node['role-chef'][:webui][:version]
            10:   end
            11: 

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/role-chef/recipes/webui.rb:8:in `block in from_file'

           git("https://github.com/chef-boneyard/chef-server-webui.git") do
             action [:sync]
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             destination "https://github.com/chef-boneyard/chef-server-webui.git"
             enable_checkout true
             revision "11.1.5"
             remote "origin"
             checkout_branch "deploy"
             declared_type :git
             cookbook_name "role-chef"
             recipe_name "webui"
           end

           Platform:
           ---------
           x86_64-linux

I realized what the error was, though.

The following code works:

application '/srv/my-app' do
  git do
    repository 'https://github.com/daharon/my-app.git' 
    revision 'v1.0.0'  # A git tag.
  end

  bundle_install
  rails
  unicorn
end
coderanger commented 7 years ago

You need to depend on application_git too if you want to use the shorter syntax.