summaryrefslogtreecommitdiff
path: root/morphlib/gitdir_tests.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-05 15:01:57 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-05 18:34:47 +0000
commitb4a4c1a772d80e7fd764ecea878cfa86c07edd7e (patch)
tree6592dc7205c943d07ae3dd132e01bc03956c987f /morphlib/gitdir_tests.py
parentac9e6787cd2b82bc37b9ba71d09d44aac71f85b1 (diff)
downloadmorph-b4a4c1a772d80e7fd764ecea878cfa86c07edd7e.tar.gz
Add GitDirectory.ref_exists() method
This allows checking if a ref exists without requiring the caller to use a try:, except: block.
Diffstat (limited to 'morphlib/gitdir_tests.py')
-rw-r--r--morphlib/gitdir_tests.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/morphlib/gitdir_tests.py b/morphlib/gitdir_tests.py
index 456e3716..10b3b7e5 100644
--- a/morphlib/gitdir_tests.py
+++ b/morphlib/gitdir_tests.py
@@ -162,6 +162,13 @@ class GitDirectoryContentsTests(unittest.TestCase):
self.assertEqual(len(tree), 40)
self.assertNotEqual(commit, tree)
+ def test_ref_exists(self):
+ gd = morphlib.gitdir.GitDirectory(self.dirname)
+ self.assertFalse(gd.ref_exists('non-existant-ref'))
+ self.assertTrue(gd.ref_exists('master'))
+ self.assertFalse(
+ gd.ref_exists('0000000000000000000000000000000000000000'))
+
def test_store_blob_with_string(self):
gd = morphlib.gitdir.GitDirectory(self.dirname)
sha1 = gd.store_blob('test string')