From 5d9b130ec7705bb7318974bc5719269203c87791 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Jakub=20Ku=C5=BAma?= Date: Tue, 10 Jun 2008 02:53:12 +0200 Subject: [PATCH] Added revision specyfing for git repositories in plugin command --- railties/lib/commands/plugin.rb | 40 ++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 11 deletions(-) diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb index 105819c..bca0a9f 100644 --- a/railties/lib/commands/plugin.rb +++ b/railties/lib/commands/plugin.rb @@ -43,6 +43,16 @@ # plugin is pulled via `svn checkout` or `svn export` but looks # exactly the same. # +# Specifying revisions: +# +# * Subversion revision is a single integer. +# +# * Git revision format: +# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental' +# - short: 'experimental' (equivalent to 'refs/heads/experimental') +# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0') +# +# # This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com) # and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php) @@ -175,7 +185,7 @@ class Plugin method ||= rails_env.best_install_method? if :http == method method = :export if svn_url? - method = :clone if git_url? + method = :pull if git_url? end uninstall if installed? and options[:force] @@ -255,8 +265,8 @@ class Plugin end end - def install_using_clone(options = {}) - git_command :clone, options + def install_using_pull(options = {}) + git_command :pull, options end def svn_command(cmd, options = {}) @@ -271,12 +281,20 @@ class Plugin def git_command(cmd, options = {}) root = rails_env.root - mkdir_p "#{root}/vendor/plugins" - base_cmd = "git #{cmd} --depth 1 #{uri} \"#{root}/vendor/plugins/#{name}\"" - puts base_cmd if $verbose - puts "removing: #{root}/vendor/plugins/#{name}/.git" - system(base_cmd) - rm_rf "#{root}/vendor/plugins/#{name}/.git" + mkdir_p "#{root}/vendor/plugins/#{name}" + Dir.chdir "#{root}/vendor/plugins/#{name}" do + init_cmd = "git init" + init_cmd += " -q" if options[:quiet] and not $verbose + puts init_cmd if $verbose + system(init_cmd) + base_cmd = "git #{cmd} --depth 1 #{uri}" + base_cmd += " -q" if options[:quiet] and not $verbose + base_cmd += " #{options[:revision]}" if options[:revision] + puts base_cmd if $verbose + system(base_cmd) + puts "removing: .git" if $verbose + rm_rf ".git" + end end def guess_name(url) @@ -756,8 +774,8 @@ module Commands "Suppresses the output from installation.", "Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true } o.on( "-r REVISION", "--revision REVISION", - "Checks out the given revision from subversion.", - "Ignored if subversion is not used.") { |v| @options[:revision] = v } + "Checks out the given revision from subversion or git.", + "Ignored if subversion/git is not used.") { |v| @options[:revision] = v } o.on( "-f", "--force", "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true } o.separator "" -- 1.5.4.3