Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Git#push when remote does not exist returns silently

  • Loading branch information...
commit 397604d2a9478473568a47f5bfb5a3798b9e7bdd 1 parent eed756a
Bryan Ash authored October 21, 2011
1  lib/kumade/git.rb
@@ -11,6 +11,7 @@ def self.environments
11 11
     end
12 12
 
13 13
     def push(branch, remote = 'origin', force = false)
  14
+      return unless remote_exists?(remote)
14 15
       command = ["git push"]
15 16
       command << "-f" if force
16 17
       command << remote
47  spec/kumade/git_spec.rb
@@ -43,27 +43,42 @@
43 43
 describe Kumade::Git, "#push", :with_mock_outputter do
44 44
   let(:branch)       { 'branch' }
45 45
   let(:remote)       { 'my-remote' }
46  
-  let(:command_line) { stub("Kumade::CommandLine instance", :run_or_error => true) }
47 46
 
48  
-  before do
49  
-    Kumade::CommandLine.stubs(:new => command_line)
50  
-  end
  47
+  context "when the remote exists" do
  48
+    let(:command_line) { stub("Kumade::CommandLine instance", :run_or_error => true) }
51 49
 
52  
-  it "pushes to the correct remote" do
53  
-    subject.push(branch, remote)
54  
-    Kumade::CommandLine.should have_received(:new).with("git push #{remote} #{branch}")
55  
-    command_line.should have_received(:run_or_error).once
56  
-  end
  50
+    before do
  51
+      Kumade::CommandLine.stubs(:new => command_line)
  52
+      subject.stubs(:remote_exists? => true)
  53
+    end
  54
+
  55
+    it "pushes to the correct remote" do
  56
+      subject.push(branch, remote)
  57
+      Kumade::CommandLine.should have_received(:new).with("git push #{remote} #{branch}")
  58
+      command_line.should have_received(:run_or_error).once
  59
+    end
57 60
 
58  
-  it "can force push" do
59  
-    subject.push(branch, remote, true)
60  
-    Kumade::CommandLine.should have_received(:new).with("git push -f #{remote} #{branch}")
61  
-    command_line.should have_received(:run_or_error).once
  61
+    it "can force push" do
  62
+      subject.push(branch, remote, true)
  63
+      Kumade::CommandLine.should have_received(:new).with("git push -f #{remote} #{branch}")
  64
+      command_line.should have_received(:run_or_error).once
  65
+    end
  66
+
  67
+    it "prints a success message" do
  68
+      subject.push(branch, remote)
  69
+      Kumade.configuration.outputter.should have_received(:success).with("Pushed #{branch} -> #{remote}")
  70
+    end
62 71
   end
63 72
 
64  
-  it "prints a success message" do
65  
-    subject.push(branch, remote)
66  
-    Kumade.configuration.outputter.should have_received(:success).with("Pushed #{branch} -> #{remote}")
  73
+  context "when the remote does not exist" do
  74
+    before do
  75
+      subject.stubs(:remote_exists? => false)
  76
+    end
  77
+    
  78
+    it "returns silently" do
  79
+      subject.push(branch)
  80
+      Kumade::CommandLine.should have_received(:new).never
  81
+    end
67 82
   end
68 83
 end
69 84
 

0 notes on commit 397604d

Please sign in to comment.
Something went wrong with that request. Please try again.