public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
commit controller was rejecting initial commits (because there are no 
branches when the repository is unborn)
timcharper (author)
Wed Apr 02 13:02:22 -0700 2008
commit  46a459f1d00b913af3d8cc5a0df4035fea838992
tree    2f8c5a0cc7619eb9558216b2fe4280520358a92c
parent  e35c34e157f3118428f2f1b0a9eb8f8e1275c9f1
...
23
24
25
26
 
 
 
 
 
27
28
29
30
 
 
31
32
33
34
35
36
 
37
38
39
...
23
24
25
 
26
27
28
29
30
31
32
 
 
33
34
35
36
37
38
39
 
40
41
42
43
0
@@ -23,17 +23,21 @@ class CommitController < ApplicationController
0
   end
0
   
0
   protected
0
-
0
+
0
+ def ok_to_proceed_with_partial_commit?
0
+ (! git.branch.current_name.nil?) || git.initial_commit_pending?
0
+ end
0
+
0
     def run_partial_commit
0
       @base = git.git_base
0
- current_branch_name = git.branch.current_name
0
- if current_branch_name.nil?
0
+
0
+ unless ok_to_proceed_with_partial_commit?
0
         render "not_on_a_branch"
0
         return false
0
       end
0
       
0
       target_file_or_dir = git.paths.first
0
- puts "<h1>Committing Files in ‘#{htmlize(shorten(target_file_or_dir, ENV['TM_PROJECT_DIRECTORY'] || @base))}’ on branch ‘#{htmlize(current_branch_name)}’</h1>"
0
+ puts "<h1>Committing Files in ‘#{htmlize(shorten(target_file_or_dir, ENV['TM_PROJECT_DIRECTORY'] || @base))}’ on branch ‘#{htmlize(git.branch.current_name)}’</h1>"
0
       flush
0
 
0
       files, statuses = [], []
...
3
4
5
6
 
7
8
9
10
11
...
38
39
40
41
42
43
44
45
46
47
 
 
 
48
49
50
51
 
 
 
 
 
 
 
 
52
53
54
...
3
4
5
 
6
7
 
8
9
10
...
37
38
39
 
 
 
 
 
 
 
40
41
42
43
 
 
 
44
45
46
47
48
49
50
51
52
53
54
0
@@ -3,9 +3,8 @@ require File.dirname(__FILE__) + '/../spec_helper'
0
 describe CommitController do
0
   include SpecHelpers
0
   before(:each) do
0
- @controller = CommitController.new
0
+ @controller = CommitController.singleton_new
0
     @git = Git.singleton_new
0
- CommitController.stub!(:new).and_return(@controller)
0
     Git.command_response["status"] = fixture_file("status_output.txt")
0
   end
0
   
0
@@ -38,17 +37,18 @@ describe CommitController do
0
     end
0
   end
0
   
0
- describe "when not on a branch" do
0
- before(:each) do
0
- Git.command_response["branch"] = "* (no branch)"
0
- @output = capture_output do
0
- dispatch(:controller => "commit")
0
- end
0
- end
0
+ it "should NOT be OK to proceed when not on a branch but performing an initial commit" do
0
+ @git.branch.should_receive(:current_name).and_return(nil)
0
+ @git.should_receive(:initial_commit_pending?).and_return(false)
0
     
0
- it "freak out" do
0
- @output.should include("Eegad")
0
- end
0
+ @controller.send(:ok_to_proceed_with_partial_commit?).should == false
0
+ end
0
+
0
+ it "should be OK to proceed when not on a branch but performing an initial commit" do
0
+ @git.branch.should_receive(:current_name).and_return(nil)
0
+ @git.should_receive(:initial_commit_pending?).and_return(true)
0
+
0
+ @controller.send(:ok_to_proceed_with_partial_commit?).should == true
0
   end
0
   
0
   describe "when in the middle of a merge" do

Comments

    No one has commented yet.