Permalink
Browse files

Add porcelain 'list-tags'.

  • Loading branch information...
1 parent a0f0170 commit 03578f1dcf6a89f9d8877578c4813f9a390aca8a Ryan Faulkner committed with Feb 28, 2014
Showing with 29 additions and 0 deletions.
  1. +2 −0 NEWS
  2. +13 −0 dulwich/porcelain.py
  3. +14 −0 dulwich/tests/test_porcelain.py
View
2 NEWS
@@ -2,6 +2,8 @@
IMPROVEMENTS
+ * Add porcelain 'list_tags'. (Ryan Faulkner)
+
* Add porcelain 'push'. (Ryan Faulkner)
* Add porcelain 'pull'. (Ryan Faulkner)
View
@@ -46,6 +46,7 @@
* commit-tree
* diff-tree
* init
+ * list-tags
* pull
* push
* remove
@@ -374,6 +375,18 @@ def tag(repo, tag, author, message):
r.refs['refs/tags/' + tag] = tag_obj.id
+def list_tags(repo, outstream=sys.stdout):
+ """List all tags.
+
+ :param repo: Path to repository
+ :param outstream: Stream to write tags to
+ """
+ r = open_repo(repo)
+ tags = list(r.refs.as_dict("refs/tags"))
+ tags.sort()
+ return tags
+
+
def reset(repo, mode, committish="HEAD"):
"""Reset current HEAD to the specified state.
@@ -346,6 +346,20 @@ def test_simple(self):
self.assertEquals(tags.keys()[0], tag)
+class ListTagsTests(PorcelainTestCase):
+
+ def test_empty(self):
+ tags = porcelain.list_tags(self.repo.path)
+ self.assertEquals([], tags)
+
+ def test_simple(self):
+ self.repo.refs["refs/tags/foo"] = "aa" * 20
+ self.repo.refs["refs/tags/bar/bla"] = "bb" * 20
+ tags = porcelain.list_tags(self.repo.path)
+
+ self.assertEquals(["bar/bla", "foo"], tags)
+
+
class ResetTests(PorcelainTestCase):
def test_hard_head(self):

0 comments on commit 03578f1

Please sign in to comment.