| |   |
| 77 | 77 | puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>" |
| 78 | 78 | flush |
| 79 | 79 | |
| 80 | | with_submodule_stashing do |
| 80 | with_submodule_cacheing do |
| 81 | 81 | @result = git.merge(@merge_from_branch) |
| 82 | 82 | render "merge" |
| 83 | 83 | true |
| … | … | |
| 147 | 147 | end |
| 148 | 148 | |
| 149 | 149 | def switch_local(target_branch) |
| 150 | | with_submodule_stashing do |
| 150 | with_submodule_cacheing do |
| 151 | 151 | output = git.branch.switch(target_branch) |
| 152 | 152 | case output |
| 153 | 153 | when /fatal: you need to resolve your current index first/ |
| toggle raw diff |
--- a/Support/app/controllers/branch_controller.rb
+++ b/Support/app/controllers/branch_controller.rb
@@ -77,7 +77,7 @@ class BranchController < ApplicationController
puts "<h2>Merging #{@merge_from_branch} into #{@c_branch}</h2>"
flush
- with_submodule_stashing do
+ with_submodule_cacheing do
@result = git.merge(@merge_from_branch)
render "merge"
true
@@ -147,7 +147,7 @@ class BranchController < ApplicationController
end
def switch_local(target_branch)
- with_submodule_stashing do
+ with_submodule_cacheing do
output = git.branch.switch(target_branch)
case output
when /fatal: you need to resolve your current index first/ |
| |   |
| 48 | 48 | |
| 49 | 49 | puts "<p>Pulling from remote source '#{source}'\n</p>" |
| 50 | 50 | |
| 51 | | with_submodule_stashing do |
| 51 | with_submodule_cacheing do |
| 52 | 52 | output = run_pull(source, remote_branch_name) |
| 53 | 53 | puts "<pre>#{output[:text]}</pre>" |
| 54 | 54 | |
| toggle raw diff |
--- a/Support/app/controllers/remote_controller.rb
+++ b/Support/app/controllers/remote_controller.rb
@@ -48,7 +48,7 @@ class RemoteController < ApplicationController
puts "<p>Pulling from remote source '#{source}'\n</p>"
- with_submodule_stashing do
+ with_submodule_cacheing do
output = run_pull(source, remote_branch_name)
puts "<pre>#{output[:text]}</pre>"
|
| |   |
| 50 | 50 | path |
| 51 | 51 | end |
| 52 | 52 | |
| 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)) |
| 55 | 55 | end |
| 56 | 56 | |
| 57 | 57 | def abs_path |
| 58 | 58 | @abs_path ||= File.join(@base.git_base, @path) |
| 59 | 59 | end |
| 60 | 60 | |
| 61 | | def stash |
| 61 | def cache |
| 62 | 62 | 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) |
| 66 | 66 | true |
| 67 | 67 | end |
| 68 | 68 | end |
| 69 | 69 | |
| 70 | 70 | def restore |
| 71 | | if ! File.exist?(abs_path) && File.exist?(abs_stash_path) |
| 71 | if ! File.exist?(abs_path) && File.exist?(abs_cache_path) |
| 72 | 72 | 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) |
| 74 | 74 | end |
| 75 | 75 | end |
| 76 | 76 | end |
| toggle raw diff |
--- a/Support/lib/commands/submodule.rb
+++ b/Support/lib/commands/submodule.rb
@@ -50,27 +50,27 @@ class SCM::Git::Submodule < SCM::Git::CommandProxyBase
path
end
- def abs_stash_path
- @abs_stash_path ||= File.join(@base.git_base, ".git/submodule_stash", MD5.hexdigest(path + "\n" + url))
+ def abs_cache_path
+ @abs_cache_path ||= File.join(@base.git_base, ".git/submodule_cache", MD5.hexdigest(path + "\n" + url))
end
def abs_path
@abs_path ||= File.join(@base.git_base, @path)
end
- def stash
+ def cache
if File.exist?(abs_path)
- FileUtils.rm_rf(abs_stash_path)
- FileUtils.mkdir_p(File.dirname(abs_stash_path))
- FileUtils.mv(abs_path, abs_stash_path, :force => true)
+ FileUtils.rm_rf(abs_cache_path)
+ FileUtils.mkdir_p(File.dirname(abs_cache_path))
+ FileUtils.mv(abs_path, abs_cache_path, :force => true)
true
end
end
def restore
- if ! File.exist?(abs_path) && File.exist?(abs_stash_path)
+ if ! File.exist?(abs_path) && File.exist?(abs_cache_path)
FileUtils.mkdir_p(File.dirname(abs_path))
- FileUtils.mv(abs_stash_path, abs_path, :force => true)
+ FileUtils.mv(abs_cache_path, abs_path, :force => true)
end
end
end |
| |   |
| 88 | 88 | end |
| 89 | 89 | |
| 90 | 90 | 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 |
| 92 | 92 | @set_branch_to_choose.call("task") |
| 93 | 93 | |
| 94 | 94 | git = Git.singleton_new |
| 95 | | @submodule = stub("submodule", :stash => true, :restore => true) |
| 95 | @submodule = stub("submodule", :cache => true, :restore => true) |
| 96 | 96 | git.submodule.should_receive(:all).any_number_of_times.and_return([@submodule]) |
| 97 | 97 | git.submodule.should_receive(:init_and_update) |
| 98 | 98 | output = capture_output do |
| … | … | |
| 148 | 148 | output.should include("Success!") |
| 149 | 149 | end |
| 150 | 150 | |
| 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) |
| 153 | 153 | capture_output { dispatch(:controller => "branch", :action => "merge") } |
| 154 | 154 | end |
| 155 | 155 | end |
| toggle raw diff |
--- a/Support/spec/controllers/branch_controller_spec.rb
+++ b/Support/spec/controllers/branch_controller_spec.rb
@@ -88,11 +88,11 @@ EOF
end
describe "when you have submodules" do
- it "should stash, restore, then call submodules.init_and_update" do
+ it "should cache, restore, then call submodules.init_and_update" do
@set_branch_to_choose.call("task")
git = Git.singleton_new
- @submodule = stub("submodule", :stash => true, :restore => true)
+ @submodule = stub("submodule", :cache => true, :restore => true)
git.submodule.should_receive(:all).any_number_of_times.and_return([@submodule])
git.submodule.should_receive(:init_and_update)
output = capture_output do
@@ -148,8 +148,8 @@ EOF
output.should include("Success!")
end
- it "should run with_submodule_stashing" do
- @controller.should_receive(:with_submodule_stashing)
+ it "should run with_submodule_cacheing" do
+ @controller.should_receive(:with_submodule_cacheing)
capture_output { dispatch(:controller => "branch", :action => "merge") }
end
end |
| |   |
| 67 | 67 | @output.should include("Branch 'asdf': dc29d3d..05f9ad9") |
| 68 | 68 | end |
| 69 | 69 | |
| 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) |
| 72 | 72 | capture_output { dispatch :controller => "remote", :action => "pull" } |
| 73 | 73 | end |
| 74 | 74 | end |
| toggle raw diff |
--- a/Support/spec/controllers/remote_controller_spec.rb
+++ b/Support/spec/controllers/remote_controller_spec.rb
@@ -67,8 +67,8 @@ describe RemoteController do
@output.should include("Branch 'asdf': dc29d3d..05f9ad9")
end
- it "should with_submodule_stashing" do
- @controller.should_receive(:with_submodule_stashing)
+ it "should with_submodule_cacheing" do
+ @controller.should_receive(:with_submodule_cacheing)
capture_output { dispatch :controller => "remote", :action => "pull" }
end
end |
| |   |
| 57 | 57 | @submodule.stub!(:url).and_return("git@url.com/path/to/repo.git") |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | | it "should stash" do |
| 60 | it "should cache" do |
| 61 | 61 | 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 |
| 66 | 66 | end |
| 67 | 67 | |
| 68 | 68 | it "should restore when submodule isn't in working copy" do |
| 69 | 69 | 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) |
| 71 | 71 | 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) |
| 73 | 73 | @submodule.restore |
| 74 | 74 | end |
| 75 | 75 | end |
| toggle raw diff |
--- a/Support/spec/lib/commands/submodule_spec.rb
+++ b/Support/spec/lib/commands/submodule_spec.rb
@@ -57,19 +57,19 @@ EOF
@submodule.stub!(:url).and_return("git@url.com/path/to/repo.git")
end
- it "should stash" do
+ it "should cache" do
File.should_receive(:exist?).with(@submodule.abs_path).and_return(true)
- FileUtils.should_receive(:mkdir_p).with(File.join(@git.git_base, ".git/submodule_stash"))
- FileUtils.should_receive(:rm_rf).with(@submodule.abs_stash_path)
- FileUtils.should_receive(:mv).with(@submodule.abs_path, @submodule.abs_stash_path, :force => true)
- @submodule.stash
+ FileUtils.should_receive(:mkdir_p).with(File.join(@git.git_base, ".git/submodule_cache"))
+ FileUtils.should_receive(:rm_rf).with(@submodule.abs_cache_path)
+ FileUtils.should_receive(:mv).with(@submodule.abs_path, @submodule.abs_cache_path, :force => true)
+ @submodule.cache
end
it "should restore when submodule isn't in working copy" do
File.should_receive(:exist?).with(@submodule.abs_path).and_return(false)
- File.should_receive(:exist?).with(@submodule.abs_stash_path).and_return(true)
+ 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_stash_path, @submodule.abs_path, :force => true)
+ FileUtils.should_receive(:mv).with(@submodule.abs_cache_path, @submodule.abs_path, :force => true)
@submodule.restore
end
end |