Sha256: b06c18a73c51f084cf3e8a608719cff21277571df5ac78766cafcaa31af539f6

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

module PoolParty    
  class Git
        
    virtual_resource(:git) do
      
      def loaded(opts={}, parent=self)
        has_git_repos
      end
            
      def has_git_repos
        has_package(:name => "git-core")
        has_directory(:name => "#{cwd}")
        
        exec({:name => "git-#{name}", :requires => package(:name => "git-core")}) do
          command parent.user ? "git clone #{parent.user}@#{parent.source} #{parent.path}" : "git clone #{parent.source} #{parent.to ? parent.to : ""}"
          cwd "#{parent.cwd if parent.cwd}"
          creates "#{::File.join( (parent.cwd ? parent.cwd : cwd), ::File.basename(parent.source, ::File.extname(parent.source)) )}/.git"

          exec(:name => "update-#{name}") do
            cwd ::File.dirname(parent.creates)
            command "git pull"
          end
        end
      end
      
      # Since git is not a native type, we have to say which core resource
      # it is using to be able to require it
      def class_type_name
        "exec"
      end
      
      # Because we are requiring an exec, instead of a built-in package of the git, we have to overload
      # the to_s method and prepend it with the same name as above
      def key
        "git-#{name}"
      end
      
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
auser-poolparty-0.2.22 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.23 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.24 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.25 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.26 lib/poolparty/plugins/git.rb