Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9049

Show
Ignore:
Timestamp:
03/17/08 21:44:16 (2 months ago)
Author:
david
Message:

Added support for installing plugins hosted at git repositories (closes #11294) [danger]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r9017 r9049  
    11*SVN* 
     2 
     3* Added support for installing plugins hosted at git repositories #11294 [danger] 
    24 
    35* Fixed that script/generate would not look for plugin generators in plugin_paths #11000 [glv] 
  • trunk/railties/lib/commands/plugin.rb

    r8921 r9049  
    163163  end 
    164164   
     165  def git_url? 
     166    @uri =~ /^git:\/\// || @url =~ /\.git$/ 
     167  end 
     168   
    165169  def installed? 
    166170    File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \ 
     
    170174  def install(method=nil, options = {}) 
    171175    method ||= rails_env.best_install_method? 
    172     method   = :export if method == :http and svn_url? 
     176    if :http == method 
     177      method = :export if svn_url? 
     178      method = :clone  if git_url? 
     179    end 
    173180 
    174181    uninstall if installed? and options[:force] 
     
    248255      end 
    249256    end 
     257     
     258    def install_using_clone(options = {}) 
     259      git_command :clone, options 
     260    end 
    250261 
    251262    def svn_command(cmd, options = {}) 
     
    258269      system(base_cmd) 
    259270    end 
     271     
     272    def git_command(cmd, options = {}) 
     273      root = rails_env.root 
     274      mkdir_p "#{root}/vendor/plugins" 
     275      base_cmd = "git #{cmd} --depth 1 #{uri} \"#{root}/vendor/plugins/#{name}\"" 
     276      puts base_cmd if $verbose 
     277      puts "removing: #{root}/vendor/plugins/#{name}/.git" 
     278      system(base_cmd) 
     279      rm_rf "#{root}/vendor/plugins/#{name}/.git" 
     280    end 
    260281 
    261282    def guess_name(url) 
     
    264285        @name = File.basename(File.dirname(url)) 
    265286      end 
     287      @name.gsub!(/\.git$/, '') if @name =~ /\.git$/ 
    266288    end 
    267289     
     
    448470        o.separator "  Install a plugin from a subversion URL:" 
    449471        o.separator "    #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" 
     472        o.separator "  Install a plugin from a git URL:" 
     473        o.separator "    #{@script_name} install git://github.com/SomeGuy/my_awesome_plugin.git\n" 
    450474        o.separator "  Install a plugin and add a svn:externals entry to vendor/plugins" 
    451475        o.separator "    #{@script_name} install -x continuous_builder\n"