summaryrefslogtreecommitdiff
path: root/morphlib/gitdir_tests.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-17 13:12:54 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-17 14:34:13 +0000
commit31b0ed683dfe0d99bc82accc05ad329fe527d68f (patch)
tree073970f19d14db2b40cd7421436b5f531d2ea14a /morphlib/gitdir_tests.py
parent34504edc0e8d7c500434c20d7bad52b1f5f2014c (diff)
downloadmorph-31b0ed683dfe0d99bc82accc05ad329fe527d68f.tar.gz
gitdir: add HEAD property to find the current branch
This is needed for status to tell if a repo is checked out in an unexpected branch.
Diffstat (limited to 'morphlib/gitdir_tests.py')
-rw-r--r--morphlib/gitdir_tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/morphlib/gitdir_tests.py b/morphlib/gitdir_tests.py
index 175b8ee7..84b8787a 100644
--- a/morphlib/gitdir_tests.py
+++ b/morphlib/gitdir_tests.py
@@ -137,3 +137,13 @@ class GitDirectoryContentsTests(unittest.TestCase):
gd = morphlib.gitdir.GitDirectory(self.dirname)
self.assertRaises(morphlib.gitdir.InvalidRefError,
gd.read_file, 'bar', 'no-such-ref')
+
+ def test_HEAD(self):
+ gd = morphlib.gitdir.GitDirectory(self.dirname)
+ self.assertEqual(gd.HEAD, 'master')
+
+ gd.branch('foo', 'master')
+ self.assertEqual(gd.HEAD, 'master')
+
+ gd.checkout('foo')
+ self.assertEqual(gd.HEAD, 'foo')