Commit 81323ac226297427937a785d6e654c29c48523c9
- Date: Wed Apr 30 17:42:23 +0000 2008
- Committer: Tim Harper (timcharper@gmail.com)
- Author: Tim Harper (timcharper@gmail.com)
- Commit SHA1: 81323ac226297427937a785d6e654c29c48523c9
- Tree SHA1: e1d5e618bc6abd7d5eb10ada9b6e334477807e4e
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
| |   |
| 75 | 75 | end |
| 76 | 76 | |
| 77 | 77 | puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>" |
| 78 | | flush |
| 79 | 78 | |
| 80 | 79 | with_submodule_cacheing do |
| 81 | 80 | @result = git.merge(@merge_from_branch) |
| 82 | 81 | render "merge" |
| 83 | | true |
| 84 | 82 | end |
| 85 | 83 | rescan_project |
| 84 | true |
| 86 | 85 | end |
| 87 | 86 | |
| 88 | 87 | protected |
| toggle raw diff |
--- a/Support/app/controllers/branch_controller.rb
+++ b/Support/app/controllers/branch_controller.rb
@@ -75,14 +75,13 @@ class BranchController < ApplicationController
end
puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>"
- flush
with_submodule_cacheing do
@result = git.merge(@merge_from_branch)
render "merge"
- true
end
rescan_project
+ true
end
protected |
| |   |
| 1 | 1 | module SubmoduleHelper |
| 2 | 2 | module Update |
| 3 | flush |
| 3 | 4 | def with_submodule_cacheing(&block) |
| 4 | 5 | git.submodule.all.each { |m| m.cache } |
| 5 | 6 | begin |
| toggle raw diff |
--- a/Support/app/helpers/submodule_helper.rb
+++ b/Support/app/helpers/submodule_helper.rb
@@ -1,5 +1,6 @@
module SubmoduleHelper
module Update
+ flush
def with_submodule_cacheing(&block)
git.submodule.all.each { |m| m.cache }
begin |
| |   |
| 68 | 68 | end |
| 69 | 69 | |
| 70 | 70 | 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) |
| 72 | 73 | FileUtils.mkdir_p(File.dirname(abs_path)) |
| 73 | 74 | FileUtils.mv(abs_cache_path, abs_path, :force => true) |
| 74 | 75 | end |
| … | … | |
| 77 | 77 | end |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | class Dir |
| 81 | def self.has_a_file?(abs_path) |
| 82 | Dir[abs_path + "/**/*"].any? {|f| File.file?(f) } |
| 83 | end |
| 84 | end |
| toggle raw diff |
--- a/Support/lib/commands/submodule.rb
+++ b/Support/lib/commands/submodule.rb
@@ -68,7 +68,8 @@ class SCM::Git::Submodule < SCM::Git::CommandProxyBase
end
def restore
- if ! File.exist?(abs_path) && File.exist?(abs_cache_path)
+ if File.exist?(abs_cache_path) && ! Dir.has_a_file?(abs_path)
+ FileUtils.rm_rf(abs_path)
FileUtils.mkdir_p(File.dirname(abs_path))
FileUtils.mv(abs_cache_path, abs_path, :force => true)
end
@@ -76,3 +77,8 @@ class SCM::Git::Submodule < SCM::Git::CommandProxyBase
end
end
+class Dir
+ def self.has_a_file?(abs_path)
+ Dir[abs_path + "/**/*"].any? {|f| File.file?(f) }
+ end
+end
\ No newline at end of file |
| |   |
| 341 | 341 | end |
| 342 | 342 | end |
| 343 | 343 | |
| 344 | def logger |
| 345 | @logger ||= |
| 346 | begin |
| 347 | require 'logger' |
| 348 | Logger.new(ROOT + "/git.log") |
| 349 | end |
| 350 | end |
| 344 | 351 | |
| 345 | 352 | protected |
| 346 | 353 | def get_range_arg(options, keys = [:revisions, :branches, :tags]) |
| toggle raw diff |
--- a/Support/lib/git.rb
+++ b/Support/lib/git.rb
@@ -341,6 +341,13 @@ module SCM
end
end
+ def logger
+ @logger ||=
+ begin
+ require 'logger'
+ Logger.new(ROOT + "/git.log")
+ end
+ end
protected
def get_range_arg(options, keys = [:revisions, :branches, :tags]) |
| |   |
| 66 | 66 | end |
| 67 | 67 | |
| 68 | 68 | 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) |
| 70 | 70 | File.should_receive(:exist?).with(@submodule.abs_cache_path).and_return(true) |
| 71 | 71 | FileUtils.should_receive(:mkdir_p).with(File.dirname(@submodule.abs_path)) |
| 72 | 72 | FileUtils.should_receive(:mv).with(@submodule.abs_cache_path, @submodule.abs_path, :force => true) |
| toggle raw diff |
--- a/Support/spec/lib/commands/submodule_spec.rb
+++ b/Support/spec/lib/commands/submodule_spec.rb
@@ -66,7 +66,7 @@ EOF
end
it "should restore when submodule isn't in working copy" do
- File.should_receive(:exist?).with(@submodule.abs_path).and_return(false)
+ Dir.should_receive(:has_a_file?).with(@submodule.abs_path).and_return(false)
File.should_receive(:exist?).with(@submodule.abs_cache_path).and_return(true)
FileUtils.should_receive(:mkdir_p).with(File.dirname(@submodule.abs_path))
FileUtils.should_receive(:mv).with(@submodule.abs_cache_path, @submodule.abs_path, :force => true) |