@@ -300,3 +300,27 @@ def test_log_with_path_and_options(self, git):
300300 # # Commit.expects(:find_all).with(other_repo, ref, :max_count => 1).returns([stub()])
301301 # delta_commits = self.repo.commit_deltas_from(other_repo)
302302 # assert_equal(3, len(delta_commits))
303+
304+ def test_is_dirty_with_bare_repository (self ):
305+ self .repo .bare = True
306+ assert_false (self .repo .is_dirty )
307+
308+ @patch (Git , '_call_process' )
309+ def test_is_dirty_with_clean_working_dir (self , git ):
310+ self .repo .bare = False
311+ git .return_value = ''
312+ assert_false (self .repo .is_dirty )
313+ assert_equal (git .call_args , (('diff' , 'HEAD' ), {}))
314+
315+ @patch (Git , '_call_process' )
316+ def test_is_dirty_with_dirty_working_dir (self , git ):
317+ self .repo .bare = False
318+ git .return_value = '''-aaa\n +bbb'''
319+ assert_true (self .repo .is_dirty )
320+ assert_equal (git .call_args , (('diff' , 'HEAD' ), {}))
321+
322+ @patch (Git , '_call_process' )
323+ def test_active_branch (self , git ):
324+ git .return_value = 'refs/heads/major-refactoring'
325+ assert_equal (self .repo .active_branch , 'major-refactoring' )
326+ assert_equal (git .call_args , (('symbolic_ref' , 'HEAD' ), {}))
0 commit comments