From 125b4875b5035dc4f6bad4351651a4236b82baeb Mon Sep 17 00:00:00 2001 From: Kai Lautaportti Date: Fri, 12 Sep 2008 22:03:56 +0300 Subject: Added a read-only property Repo.is_dirty which reflects the status of the working directory. A working directory is dirty if it has any uncommitted changes (in the working directory or in the index). Bare repositories are by nature always clean. --- test/git/test_repo.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 7550e1d6..4a5ee8ac 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -296,3 +296,21 @@ class TestRepo(object): # # Commit.expects(:find_all).with(other_repo, ref, :max_count => 1).returns([stub()]) # delta_commits = self.repo.commit_deltas_from(other_repo) # assert_equal(3, len(delta_commits)) + + def test_is_dirty_with_bare_repository(self): + self.repo.bare = True + assert_false(self.repo.is_dirty) + + @patch(Git, '_call_process') + def test_is_dirty_with_clean_working_dir(self, git): + self.repo.bare = False + git.return_value = '' + assert_false(self.repo.is_dirty) + assert_equal(git.call_args, (('diff', 'HEAD'), {})) + + @patch(Git, '_call_process') + def test_is_dirty_with_dirty_working_dir(self, git): + self.repo.bare = False + git.return_value = '''-aaa\n+bbb''' + assert_true(self.repo.is_dirty) + assert_equal(git.call_args, (('diff', 'HEAD'), {})) -- cgit v1.2.1 From fa8fe4cad336a7bdd8fb315b1ce445669138830c Mon Sep 17 00:00:00 2001 From: Kai Lautaportti Date: Fri, 12 Sep 2008 22:45:43 +0300 Subject: Added a read-only Repo.active_branch property which returns the name of the currently active branch. --- test/git/test_repo.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 4a5ee8ac..13846555 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -307,10 +307,16 @@ class TestRepo(object): git.return_value = '' assert_false(self.repo.is_dirty) assert_equal(git.call_args, (('diff', 'HEAD'), {})) - + @patch(Git, '_call_process') def test_is_dirty_with_dirty_working_dir(self, git): self.repo.bare = False git.return_value = '''-aaa\n+bbb''' assert_true(self.repo.is_dirty) assert_equal(git.call_args, (('diff', 'HEAD'), {})) + + @patch(Git, '_call_process') + def test_active_branch(self, git): + git.return_value = 'refs/heads/major-refactoring' + assert_equal(self.repo.active_branch, 'major-refactoring') + assert_equal(git.call_args, (('symbolic_ref', 'HEAD'), {})) -- cgit v1.2.1