Ticket #11294: git_support_for_railties_plugin_install.diff
| File git_support_for_railties_plugin_install.diff, 1.7 kB (added by danger, 6 months ago) |
|---|
-
railties/lib/commands/plugin.rb
old new 162 162 @uri =~ /svn(?:\+ssh)?:\/\/*/ 163 163 end 164 164 165 def git_url? 166 @uri =~ /^git:\/\// || @url =~ /\.git$/ 167 end 168 165 169 def installed? 166 170 File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \ 167 171 or rails_env.externals.detect{ |name, repo| self.uri == repo } … … 169 173 170 174 def install(method=nil, options = {}) 171 175 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 173 180 174 181 uninstall if installed? and options[:force] 175 182 … … 247 254 fetcher.fetch 248 255 end 249 256 end 257 258 def install_using_clone(options = {}) 259 git_command :clone, options 260 end 250 261 251 262 def svn_command(cmd, options = {}) 252 263 root = rails_env.root … … 257 268 puts base_cmd if $verbose 258 269 system(base_cmd) 259 270 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 260 281 261 282 def guess_name(url) 262 283 @name = File.basename(url) 263 284 if @name == 'trunk' || @name.empty? 264 285 @name = File.basename(File.dirname(url)) 265 286 end 287 @name.gsub!(/\.git$/, '') if @name =~ /\.git$/ 266 288 end 267 289 268 290 def rails_env