From 5f6ae57ee3a247d99e349d6da941941e7e33a38a Mon Sep 17 00:00:00 2001 From: ZhangJinzhu Date: Sat, 6 Mar 2010 22:49:40 +0800 Subject: [PATCH] Install plugin: pass -b/--branch BRANCH for git plugins and -r/--revision REVISION for git/subversion plugins --- railties/lib/rails/commands/plugin.rb | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb index 8bcd92a..d7a4b1a 100644 --- a/railties/lib/rails/commands/plugin.rb +++ b/railties/lib/rails/commands/plugin.rb @@ -238,9 +238,10 @@ class Plugin init_cmd += " -q" if options[:quiet] and not $verbose puts init_cmd if $verbose system(init_cmd) - base_cmd = "git pull --depth 1 #{uri}" + base_cmd = "git pull #{uri}" base_cmd += " -q" if options[:quiet] and not $verbose - base_cmd += " #{options[:revision]}" if options[:revision] + base_cmd += " #{options[:branch]}" if options[:branch] + base_cmd += options[:revision] ? " && git reset --hard #{options[:revision]}" : " --depth 1" puts base_cmd if $verbose if system(base_cmd) puts "removing: .git .gitignore" if $verbose @@ -385,6 +386,9 @@ module Commands o.on( "-r REVISION", "--revision REVISION", "Checks out the given revision from subversion or git.", "Ignored if subversion/git is not used.") { |v| @options[:revision] = v } + o.on( "-b BRANCH", "--branch BRANCH", + "Checks out the given branch 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.7.0