|
@@ -1375,3 +1375,59 @@ class FsckTests(PorcelainTestCase):
|
|
|
self.assertEqual(
|
|
|
[(obj.id, 'invalid name .git')],
|
|
|
[(sha, str(e)) for (sha, e) in porcelain.fsck(self.repo)])
|
|
|
+
|
|
|
+
|
|
|
+class DescribeTests(PorcelainTestCase):
|
|
|
+
|
|
|
+ def test_no_commits(self):
|
|
|
+ self.assertRaises(KeyError, porcelain.describe, self.repo.path)
|
|
|
+
|
|
|
+ def test_single_commit(self):
|
|
|
+ fullpath = os.path.join(self.repo.path, 'foo')
|
|
|
+ with open(fullpath, 'w') as f:
|
|
|
+ f.write("BAR")
|
|
|
+ porcelain.add(repo=self.repo.path, paths=[fullpath])
|
|
|
+ sha = porcelain.commit(
|
|
|
+ self.repo.path, message=b"Some message",
|
|
|
+ author=b"Joe <joe@example.com>",
|
|
|
+ committer=b"Bob <bob@example.com>")
|
|
|
+ self.assertEqual(
|
|
|
+ 'g{}'.format(sha[:7].decode('ascii')),
|
|
|
+ porcelain.describe(self.repo.path))
|
|
|
+
|
|
|
+ def test_tag(self):
|
|
|
+ fullpath = os.path.join(self.repo.path, 'foo')
|
|
|
+ with open(fullpath, 'w') as f:
|
|
|
+ f.write("BAR")
|
|
|
+ porcelain.add(repo=self.repo.path, paths=[fullpath])
|
|
|
+ porcelain.commit(
|
|
|
+ self.repo.path, message=b"Some message",
|
|
|
+ author=b"Joe <joe@example.com>",
|
|
|
+ committer=b"Bob <bob@example.com>")
|
|
|
+ porcelain.tag_create(self.repo.path, b"tryme", b'foo <foo@bar.com>',
|
|
|
+ b'bar', annotated=True)
|
|
|
+ self.assertEqual(
|
|
|
+ "tryme",
|
|
|
+ porcelain.describe(self.repo.path))
|
|
|
+
|
|
|
+ def test_tag_and_commit(self):
|
|
|
+ fullpath = os.path.join(self.repo.path, 'foo')
|
|
|
+ with open(fullpath, 'w') as f:
|
|
|
+ f.write("BAR")
|
|
|
+ porcelain.add(repo=self.repo.path, paths=[fullpath])
|
|
|
+ porcelain.commit(
|
|
|
+ self.repo.path, message=b"Some message",
|
|
|
+ author=b"Joe <joe@example.com>",
|
|
|
+ committer=b"Bob <bob@example.com>")
|
|
|
+ porcelain.tag_create(self.repo.path, b"tryme", b'foo <foo@bar.com>',
|
|
|
+ b'bar', annotated=True)
|
|
|
+ with open(fullpath, 'w') as f:
|
|
|
+ f.write("BAR2")
|
|
|
+ porcelain.add(repo=self.repo.path, paths=[fullpath])
|
|
|
+ sha = porcelain.commit(
|
|
|
+ self.repo.path, message=b"Some message",
|
|
|
+ author=b"Joe <joe@example.com>",
|
|
|
+ committer=b"Bob <bob@example.com>")
|
|
|
+ self.assertEqual(
|
|
|
+ 'tryme-1-g{}'.format(sha[:7].decode('ascii')),
|
|
|
+ porcelain.describe(self.repo.path))
|