diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-10-26 10:46:42 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-10-26 18:43:39 +0200 |
commit | 58ddd05147316531199b4622e122adb245c8d4bb (patch) | |
tree | d703f0f4b3c07cd632663c5ab02d7e6606590b5b | |
parent | 6849a77d80dba5b1d512bdd246c460c56c426c19 (diff) |
GitRrepository: add get_tags()
-rw-r--r-- | gbp/git.py | 19 | ||||
-rw-r--r-- | tests/test_GitRepository.py | 5 |
2 files changed, 22 insertions, 2 deletions
@@ -91,8 +91,8 @@ class GitRepository(object): @group Branches and Merging: create_branch delete_branch get_branch get_branches get_local_branches get_merge_branch get_remote_branches has_branch is_fast_forward merge set_branch - @group Tags: _build_legacy_tag create_tag delete_tag find_tag has_tag - move_tag find_version + @group Tags: _build_legacy_tag create_tag delete_tag find_tag get_tags + has_tag move_tag find_version @group Submodules: add_submodule get_submodules has_submodules update_submodules @group Patches: apply_patch format_patches @@ -334,6 +334,21 @@ class GitRepository(object): args += [ commit ] if commit else [] self._git_command("tag", args) + def get_tags(self, pattern=None): + """ + List tags + + @param pattern: only list tags matching I{pattern} + @type pattern: string + """ + args = [ '-l', pattern ] if pattern else [] + return [ line.strip() for line in self.__git_getoutput('tag', args)[0] ] + + @property + def tags(self): + """List of all tags in the repository""" + return self.get_tags() + @property def branch(self): """The currently checked out branch""" diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index fd247dc..2202e5c 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -126,6 +126,7 @@ def test_tag(): Methods tested: - L{gbp.git.GitRepository.create_tag} - L{gbp.git.GitRepository.has_tag} + - L{gbp.git.GitRepository.get_tags} >>> import gbp.git >>> repo = gbp.git.GitRepository(repo_dir) @@ -137,6 +138,10 @@ def test_tag(): >>> repo.create_tag("tag2", msg="foo") >>> repo.has_tag("tag2") True + >>> repo.get_tags() + ['tag', 'tag2'] + >>> repo.tags + ['tag', 'tag2'] """ |