public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make rake test:uncommitted work with Git.

Note : rake test:uncommitted is considering only unstaged files.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
tpope (author)
Fri Apr 18 22:42:26 -0700 2008
lifo (committer)
Tue Jul 01 21:21:59 -0700 2008
commit  3a95ee73cfbcfeada3b053c5b0fb7b5125ef12c7
tree    a026710a94e8d7ea77abdfb04ee68e5bfd85834b
parent  f5052dd8a39099e4930faafe9b01e63ced2f6391
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Make rake test:uncommitted work with Git. [Tim Pope]
0
+
0
 * Added Thin support to script/server.  #488 [Bob Klosinski]
0
 
0
 * Fix script/about in production mode.  #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic]
...
66
67
68
69
 
 
 
 
 
 
 
70
71
72
 
 
73
74
75
...
80
81
82
83
 
84
85
86
...
66
67
68
 
69
70
71
72
73
74
75
76
 
 
77
78
79
80
81
...
86
87
88
 
89
90
91
92
0
@@ -66,10 +66,16 @@ namespace :test do
0
   
0
   Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
0
     def t.file_list
0
-      changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
0
+      if File.directory?(".svn")
0
+        changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
0
+      elsif File.directory?(".git")
0
+        changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.map { |path| path.chomp }
0
+      else
0
+        abort "Not a Subversion or Git checkout."
0
+      end
0
 
0
-      models      = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb/ }
0
-      controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb/ }  
0
+      models      = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
0
+      controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
0
 
0
       unit_tests       = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
0
       functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
0
@@ -80,7 +86,7 @@ namespace :test do
0
     t.libs << 'test'
0
     t.verbose = true
0
   end
0
-  Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion)"
0
+  Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
0
 
0
   Rake::TestTask.new(:units => "db:test:prepare") do |t|
0
     t.libs << "test"

Comments