public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make script/plugin install <plugin> -r <revision> option work with git based 
plugins. [#257 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
tpope (author)
Sun Jul 13 19:24:16 -0700 2008
lifo (committer)
Sun Jul 13 19:47:22 -0700 2008
commit  5c086070824bf7dd2bc4c9ce97956d82ac3fa206
tree    3e5e524a60f8f3f04e286c04dd51cc7b60f7669c
parent  e0750d6a5c7f621e4ca12205137c0b135cab444a
...
1
2
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1,5 +1,10 @@
0
 *Edge*
0
 
0
+* Make script/plugin install <plugin> -r <revision> option work with git based plugins. #257. [Tim Pope Jakub Kuźma]. Example:
0
+
0
+  script/plugin install git://github.com/mislav/will_paginate.git -r agnostic # Installs 'agnostic' branch
0
+  script/plugin install git://github.com/dchelimsky/rspec.git -r 'tag 1.1.4'
0
+
0
 * Added Rails.initialized? flag [Josh Peek]
0
 
0
 * Make rake test:uncommitted work with Git. [Tim Pope]
...
43
44
45
 
 
 
 
 
 
 
 
 
 
46
47
48
...
175
176
177
178
 
179
180
181
...
255
256
257
258
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
261
262
...
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
...
756
757
758
759
760
 
 
761
762
763
...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
185
186
187
 
188
189
190
191
...
265
266
267
 
 
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
...
295
296
297
 
 
 
 
 
 
 
 
 
 
298
299
300
...
773
774
775
 
 
776
777
778
779
780
0
@@ -43,6 +43,16 @@
0
 #     plugin is pulled via `svn checkout` or `svn export` but looks
0
 #     exactly the same.
0
 # 
0
+# Specifying revisions:
0
+#
0
+#   * Subversion revision is a single integer.
0
+#
0
+#   * Git revision format:
0
+#     - full - 'refs/tags/1.8.0' or 'refs/heads/experimental'
0
+#     - short: 'experimental' (equivalent to 'refs/heads/experimental')
0
+#              'tag 1.8.0' (equivalent to 'refs/tags/1.8.0')
0
+#
0
+#
0
 # This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com) 
0
 # and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php)
0
 
0
@@ -175,7 +185,7 @@ class Plugin
0
     method ||= rails_env.best_install_method?
0
     if :http == method
0
       method = :export if svn_url?
0
-      method = :clone  if git_url?
0
+      method = :git    if git_url?
0
     end
0
 
0
     uninstall if installed? and options[:force]
0
@@ -255,8 +265,25 @@ class Plugin
0
       end
0
     end
0
     
0
-    def install_using_clone(options = {})
0
-      git_command :clone, options
0
+    def install_using_git(options = {})
0
+      root = rails_env.root
0
+      install_path = mkdir_p "#{root}/vendor/plugins/#{name}"
0
+      Dir.chdir install_path do
0
+        init_cmd = "git init"
0
+        init_cmd += " -q" if options[:quiet] and not $verbose
0
+        puts init_cmd if $verbose
0
+        system(init_cmd)
0
+        base_cmd = "git pull --depth 1 #{uri}"
0
+        base_cmd += " -q" if options[:quiet] and not $verbose
0
+        base_cmd += " #{options[:revision]}" if options[:revision]
0
+        puts base_cmd if $verbose
0
+        if system(base_cmd)
0
+          puts "removing: .git" if $verbose
0
+          rm_rf ".git"
0
+        else
0
+          rm_rf install_path
0
+        end
0
+      end
0
     end
0
 
0
     def svn_command(cmd, options = {})
0
@@ -268,16 +295,6 @@ class Plugin
0
       puts base_cmd if $verbose
0
       system(base_cmd)
0
     end
0
-    
0
-    def git_command(cmd, options = {})
0
-      root = rails_env.root
0
-      mkdir_p "#{root}/vendor/plugins"
0
-      base_cmd = "git #{cmd} --depth 1 #{uri} \"#{root}/vendor/plugins/#{name}\""
0
-      puts base_cmd if $verbose
0
-      puts "removing: #{root}/vendor/plugins/#{name}/.git"
0
-      system(base_cmd)
0
-      rm_rf "#{root}/vendor/plugins/#{name}/.git"
0
-    end
0
 
0
     def guess_name(url)
0
       @name = File.basename(url)
0
@@ -756,8 +773,8 @@ module Commands
0
                       "Suppresses the output from installation.",
0
                       "Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true }
0
         o.on(         "-r REVISION", "--revision REVISION",
0
-                      "Checks out the given revision from subversion.",
0
-                      "Ignored if subversion is not used.") { |v| @options[:revision] = v }
0
+                      "Checks out the given revision from subversion or git.",
0
+                      "Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
0
         o.on(         "-f", "--force",
0
                       "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
0
         o.separator   ""

Comments