This patch was inspired by multiple RSpec tag installs (RSpec edge
works with the existing script/plugin).


>From 2f47df36bc3037ccd978e9b462e654558c498286 Mon Sep 17 00:00:00 2001
From: Les Hill <[EMAIL PROTECTED]>
Date: Tue, 8 Jul 2008 15:41:35 -0400
Subject: [PATCH] script/plugin install -b BRANCH_OR_TAG git:....

Added -b option to plugin install command to checkout a git branch or
tag (ignored if not a git url).
---
 railties/lib/commands/plugin.rb |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/
plugin.rb
index ce4b0d0..991efb7 100644
--- a/railties/lib/commands/plugin.rb
+++ b/railties/lib/commands/plugin.rb
@@ -272,10 +272,16 @@ 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}\""
+      depth = options[:branch] ? '' : '--depth 1'
+      base_cmd = "git #{cmd} #{depth} #{uri} \"#{root}/vendor/plugins/
#{name}\""
       puts base_cmd if $verbose
-      puts "removing: #{root}/vendor/plugins/#{name}/.git"
       system(base_cmd)
+      if options[:branch]
+        checkout_version = "git checkout #{options[:branch]}"
+        puts checkout_version if $verbose
+        Dir.chdir("#{root}/vendor/plugins/#{name}")
{ system(checkout_version) }
+      end
+      puts "removing: #{root}/vendor/plugins/#{name}/.git"
       rm_rf "#{root}/vendor/plugins/#{name}/.git"
     end

@@ -758,6 +764,10 @@ module Commands
         o.on(         "-r REVISION", "--revision REVISION",
                       "Checks out the given revision from
subversion.",
                       "Ignored if subversion is not used.") { |v|
@options[:revision] = v }
+        o.on(         "-b BRANCH_OR_TAG", "--branch BRANCH_OR_TAG",
+                      "Checks out the given branch or tag from git.",
+                      "Ignored if git is not used.") { |v|
@options[:branch] = v }
+
         o.on(         "-f", "--force",
                       "Reinstalls a plugin if it's already
installed.") { |v| @options[:force] = true }
         o.separator   ""
--
1.5.5.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to