Commit a0a2dd806c8fc61e64c79fc6bc41923ddf6cc9f2

renamed submodule stash to submodule "cache"

Commit diff

Support/app/controllers/branch_controller.rb

 
7777 puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>"
7878 flush
7979
80 with_submodule_stashing do
80 with_submodule_cacheing do
8181 @result = git.merge(@merge_from_branch)
8282 render "merge"
8383 true
147147 end
148148
149149 def switch_local(target_branch)
150 with_submodule_stashing do
150 with_submodule_cacheing do
151151 output = git.branch.switch(target_branch)
152152 case output
153153 when /fatal: you need to resolve your current index first/
toggle raw diff

Support/app/controllers/remote_controller.rb

 
4848
4949 puts "<p>Pulling from remote source '#{source}'\n</p>"
5050
51 with_submodule_stashing do
51 with_submodule_cacheing do
5252 output = run_pull(source, remote_branch_name)
5353 puts "<pre>#{output[:text]}</pre>"
5454
toggle raw diff

Support/app/helpers/submodule_helper.rb

 
11module SubmoduleHelper
22 module Update
3 def with_submodule_stashing(&block)
4 git.submodule.all.each { |m| m.stash }
3 def with_submodule_cacheing(&block)
4 git.submodule.all.each { |m| m.cache }
55 begin
66 yield
77 ensure
toggle raw diff

Support/lib/commands/submodule.rb

 
5050 path
5151 end
5252
53 def abs_stash_path
54 @abs_stash_path ||= File.join(@base.git_base, ".git/submodule_stash", MD5.hexdigest(path + "\n" + url))
53 def abs_cache_path
54 @abs_cache_path ||= File.join(@base.git_base, ".git/submodule_cache", MD5.hexdigest(path + "\n" + url))
5555 end
5656
5757 def abs_path
5858 @abs_path ||= File.join(@base.git_base, @path)
5959 end
6060
61 def stash
61 def cache
6262 if File.exist?(abs_path)
63 FileUtils.rm_rf(abs_stash_path)
64 FileUtils.mkdir_p(File.dirname(abs_stash_path))
65 FileUtils.mv(abs_path, abs_stash_path, :force => true)
63 FileUtils.rm_rf(abs_cache_path)
64 FileUtils.mkdir_p(File.dirname(abs_cache_path))
65 FileUtils.mv(abs_path, abs_cache_path, :force => true)
6666 true
6767 end
6868 end
6969
7070 def restore
71 if ! File.exist?(abs_path) && File.exist?(abs_stash_path)
71 if ! File.exist?(abs_path) && File.exist?(abs_cache_path)
7272 FileUtils.mkdir_p(File.dirname(abs_path))
73 FileUtils.mv(abs_stash_path, abs_path, :force => true)
73 FileUtils.mv(abs_cache_path, abs_path, :force => true)
7474 end
7575 end
7676 end
toggle raw diff

Support/spec/controllers/branch_controller_spec.rb

 
8888 end
8989
9090 describe "when you have submodules" do
91 it "should stash, restore, then call submodules.init_and_update" do
91 it "should cache, restore, then call submodules.init_and_update" do
9292 @set_branch_to_choose.call("task")
9393
9494 git = Git.singleton_new
95 @submodule = stub("submodule", :stash => true, :restore => true)
95 @submodule = stub("submodule", :cache => true, :restore => true)
9696 git.submodule.should_receive(:all).any_number_of_times.and_return([@submodule])
9797 git.submodule.should_receive(:init_and_update)
9898 output = capture_output do
148148 output.should include("Success!")
149149 end
150150
151 it "should run with_submodule_stashing" do
152 @controller.should_receive(:with_submodule_stashing)
151 it "should run with_submodule_cacheing" do
152 @controller.should_receive(:with_submodule_cacheing)
153153 capture_output { dispatch(:controller => "branch", :action => "merge") }
154154 end
155155 end
toggle raw diff

Support/spec/controllers/remote_controller_spec.rb

 
6767 @output.should include("Branch 'asdf': dc29d3d..05f9ad9")
6868 end
6969
70 it "should with_submodule_stashing" do
71 @controller.should_receive(:with_submodule_stashing)
70 it "should with_submodule_cacheing" do
71 @controller.should_receive(:with_submodule_cacheing)
7272 capture_output { dispatch :controller => "remote", :action => "pull" }
7373 end
7474 end
toggle raw diff

Support/spec/lib/commands/submodule_spec.rb

 
5757 @submodule.stub!(:url).and_return("git@url.com/path/to/repo.git")
5858 end
5959
60 it "should stash" do
60 it "should cache" do
6161 File.should_receive(:exist?).with(@submodule.abs_path).and_return(true)
62 FileUtils.should_receive(:mkdir_p).with(File.join(@git.git_base, ".git/submodule_stash"))
63 FileUtils.should_receive(:rm_rf).with(@submodule.abs_stash_path)
64 FileUtils.should_receive(:mv).with(@submodule.abs_path, @submodule.abs_stash_path, :force => true)
65 @submodule.stash
62 FileUtils.should_receive(:mkdir_p).with(File.join(@git.git_base, ".git/submodule_cache"))
63 FileUtils.should_receive(:rm_rf).with(@submodule.abs_cache_path)
64 FileUtils.should_receive(:mv).with(@submodule.abs_path, @submodule.abs_cache_path, :force => true)
65 @submodule.cache
6666 end
6767
6868 it "should restore when submodule isn't in working copy" do
6969 File.should_receive(:exist?).with(@submodule.abs_path).and_return(false)
70 File.should_receive(:exist?).with(@submodule.abs_stash_path).and_return(true)
70 File.should_receive(:exist?).with(@submodule.abs_cache_path).and_return(true)
7171 FileUtils.should_receive(:mkdir_p).with(File.dirname(@submodule.abs_path))
72 FileUtils.should_receive(:mv).with(@submodule.abs_stash_path, @submodule.abs_path, :force => true)
72 FileUtils.should_receive(:mv).with(@submodule.abs_cache_path, @submodule.abs_path, :force => true)
7373 @submodule.restore
7474 end
7575 end
toggle raw diff