Skip to content

Instantly share code, notes, and snippets.

@AquaGeek
Created May 14, 2011 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AquaGeek/971804 to your computer and use it in GitHub Desktop.
Save AquaGeek/971804 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #6530
From 04deb7e63a8e7bcef1c2e47f88cd124325cfc4be Mon Sep 17 00:00:00 2001
From: eianco <eiancoun@gmail.com>
Date: Mon, 7 Mar 2011 23:18:44 -0500
Subject: [PATCH] check for installed commands prior to install gems (git/svn etc)
---
railties/lib/rails/commands/plugin.rb | 38 ++++++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb
index 048af7c..3df20c2 100644
--- a/railties/lib/rails/commands/plugin.rb
+++ b/railties/lib/rails/commands/plugin.rb
@@ -148,13 +148,17 @@ class Plugin
method = :git if git_url?
end
- uninstall if installed? and options[:force]
+ if send("have_#{method}_cmd?")
+ uninstall if installed? and options[:force]
- unless installed?
- send("install_using_#{method}", options)
- run_install_hook
+ unless installed?
+ send("install_using_#{method}", options)
+ run_install_hook
+ else
+ puts "already installed: #{name} (#{uri}). pass --force to reinstall"
+ end
else
- puts "already installed: #{name} (#{uri}). pass --force to reinstall"
+ puts "missing command line tools (git/svn etc.) required to install plugin"
end
end
@@ -201,21 +205,37 @@ class Plugin
uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb"
load uninstall_hook_file if File.exist? uninstall_hook_file
end
+
+ def have_export_cmd?
+ is_svn_installed?
+ end
def install_using_export(options = {})
svn_command :export, options
end
+ def have_checkout_cmd?
+ is_svn_installed?
+ end
+
def install_using_checkout(options = {})
svn_command :checkout, options
end
+ def have_externals_cmd?
+ is_svn_installed?
+ end
+
def install_using_externals(options = {})
externals = rails_env.externals
externals.push([@name, uri])
rails_env.externals = externals
install_using_checkout(options)
end
+
+ def have_http_cmd?
+ true
+ end
def install_using_http(options = {})
root = rails_env.root
@@ -228,6 +248,10 @@ class Plugin
end
end
+ def have_git_cmd?
+ system("git --version")
+ end
+
def install_using_git(options = {})
root = rails_env.root
mkdir_p(install_path = "#{root}/vendor/plugins/#{name}")
@@ -249,6 +273,10 @@ class Plugin
end
end
+ def is_svn_installed?
+ system("svn --version")
+ end
+
def svn_command(cmd, options = {})
root = rails_env.root
mkdir_p "#{root}/vendor/plugins"
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment