public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
fixed submodule restore process to only not restore if the given working 
path has a file inside of it. (empty folders were preventing restore)
timcharper (author)
Wed Apr 30 10:42:23 -0700 2008
commit  81323ac226297427937a785d6e654c29c48523c9
tree    e1d5e618bc6abd7d5eb10ada9b6e334477807e4e
parent  f698e13b1f3740d1b1dc5fd0ba4e3b4773e2c2e9
...
75
76
77
78
79
80
81
82
83
84
85
 
86
87
88
...
75
76
77
 
78
79
80
81
 
82
83
84
85
86
87
0
@@ -75,14 +75,13 @@ class BranchController < ApplicationController
0
     end
0
     
0
     puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>"
0
- flush
0
     
0
     with_submodule_cacheing do
0
       @result = git.merge(@merge_from_branch)
0
       render "merge"
0
- true
0
     end
0
     rescan_project
0
+ true
0
   end
0
     
0
   protected
...
1
2
 
3
4
5
...
1
2
3
4
5
6
0
@@ -1,5 +1,6 @@
0
 module SubmoduleHelper
0
   module Update
0
+ flush
0
     def with_submodule_cacheing(&block)
0
       git.submodule.all.each { |m| m.cache }
0
       begin
...
68
69
70
71
 
 
72
73
74
...
76
77
78
 
 
 
 
 
79
...
68
69
70
 
71
72
73
74
75
...
77
78
79
80
81
82
83
84
85
0
@@ -68,7 +68,8 @@ class SCM::Git::Submodule < SCM::Git::CommandProxyBase
0
     end
0
     
0
     def restore
0
- if ! File.exist?(abs_path) && File.exist?(abs_cache_path)
0
+ if File.exist?(abs_cache_path) && ! Dir.has_a_file?(abs_path)
0
+ FileUtils.rm_rf(abs_path)
0
         FileUtils.mkdir_p(File.dirname(abs_path))
0
         FileUtils.mv(abs_cache_path, abs_path, :force => true)
0
       end
0
@@ -76,3 +77,8 @@ class SCM::Git::Submodule < SCM::Git::CommandProxyBase
0
   end
0
 end
0
 
0
+class Dir
0
+ def self.has_a_file?(abs_path)
0
+ Dir[abs_path + "/**/*"].any? {|f| File.file?(f) }
0
+ end
0
+end
0
\ No newline at end of file
...
341
342
343
 
 
 
 
 
 
 
344
345
346
...
341
342
343
344
345
346
347
348
349
350
351
352
353
0
@@ -341,6 +341,13 @@ module SCM
0
       end
0
     end
0
     
0
+ def logger
0
+ @logger ||=
0
+ begin
0
+ require 'logger'
0
+ Logger.new(ROOT + "/git.log")
0
+ end
0
+ end
0
     
0
     protected
0
       def get_range_arg(options, keys = [:revisions, :branches, :tags])
...
66
67
68
69
 
70
71
72
...
66
67
68
 
69
70
71
72
0
@@ -66,7 +66,7 @@ EOF
0
     end
0
     
0
     it "should restore when submodule isn't in working copy" do
0
- File.should_receive(:exist?).with(@submodule.abs_path).and_return(false)
0
+ Dir.should_receive(:has_a_file?).with(@submodule.abs_path).and_return(false)
0
       File.should_receive(:exist?).with(@submodule.abs_cache_path).and_return(true)
0
       FileUtils.should_receive(:mkdir_p).with(File.dirname(@submodule.abs_path))
0
       FileUtils.should_receive(:mv).with(@submodule.abs_cache_path, @submodule.abs_path, :force => true)

Comments

    No one has commented yet.