Commit 81323ac226297427937a785d6e654c29c48523c9

fixed submodule restore process to only not restore if the given working path has a file inside of it. (empty folders were preventing restore)

Commit diff

Support/app/controllers/branch_controller.rb

 
7575 end
7676
7777 puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>"
78 flush
7978
8079 with_submodule_cacheing do
8180 @result = git.merge(@merge_from_branch)
8281 render "merge"
83 true
8482 end
8583 rescan_project
84 true
8685 end
8786
8887 protected
toggle raw diff

Support/app/helpers/submodule_helper.rb

 
11module SubmoduleHelper
22 module Update
3 flush
34 def with_submodule_cacheing(&block)
45 git.submodule.all.each { |m| m.cache }
56 begin
toggle raw diff

Support/lib/commands/submodule.rb

 
6868 end
6969
7070 def restore
71 if ! File.exist?(abs_path) && File.exist?(abs_cache_path)
71 if File.exist?(abs_cache_path) && ! Dir.has_a_file?(abs_path)
72 FileUtils.rm_rf(abs_path)
7273 FileUtils.mkdir_p(File.dirname(abs_path))
7374 FileUtils.mv(abs_cache_path, abs_path, :force => true)
7475 end
7777 end
7878end
7979
80class Dir
81 def self.has_a_file?(abs_path)
82 Dir[abs_path + "/**/*"].any? {|f| File.file?(f) }
83 end
84end
toggle raw diff

Support/lib/git.rb

 
341341 end
342342 end
343343
344 def logger
345 @logger ||=
346 begin
347 require 'logger'
348 Logger.new(ROOT + "/git.log")
349 end
350 end
344351
345352 protected
346353 def get_range_arg(options, keys = [:revisions, :branches, :tags])
toggle raw diff

Support/spec/lib/commands/submodule_spec.rb

 
6666 end
6767
6868 it "should restore when submodule isn't in working copy" do
69 File.should_receive(:exist?).with(@submodule.abs_path).and_return(false)
69 Dir.should_receive(:has_a_file?).with(@submodule.abs_path).and_return(false)
7070 File.should_receive(:exist?).with(@submodule.abs_cache_path).and_return(true)
7171 FileUtils.should_receive(:mkdir_p).with(File.dirname(@submodule.abs_path))
7272 FileUtils.should_receive(:mv).with(@submodule.abs_cache_path, @submodule.abs_path, :force => true)
toggle raw diff