本文整理匯總了Python中datalad.support.gitrepo.GitRepo.get_tags方法的典型用法代碼示例。如果您正苦於以下問題:Python GitRepo.get_tags方法的具體用法?Python GitRepo.get_tags怎麽用?Python GitRepo.get_tags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datalad.support.gitrepo.GitRepo
的用法示例。
在下文中一共展示了GitRepo.get_tags方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_tags
# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import get_tags [as 別名]
def test_get_tags(path):
from mock import patch
gr = GitRepo(path, create=True)
eq_(gr.get_tags(), [])
eq_(gr.describe(), None)
# Explicitly override the committer date because tests may set it to a
# fixed value, but we want to check that the returned tags are sorted by
# the committer date.
with patch.dict("os.environ", {"GIT_COMMITTER_DATE":
"Thu, 07 Apr 2005 22:13:13 +0200"}):
create_tree(gr.path, {'file': ""})
gr.add('file')
gr.commit(msg="msg")
eq_(gr.get_tags(), [])
eq_(gr.describe(), None)
gr.tag("nonannotated")
tags1 = [{'name': 'nonannotated', 'hexsha': gr.get_hexsha()}]
eq_(gr.get_tags(), tags1)
eq_(gr.describe(), None)
eq_(gr.describe(tags=True), tags1[0]['name'])
first_commit = gr.get_hexsha()
with patch.dict("os.environ", {"GIT_COMMITTER_DATE":
"Fri, 08 Apr 2005 22:13:13 +0200"}):
create_tree(gr.path, {'file': "123"})
gr.add('file')
gr.commit(msg="changed")
gr.tag("annotated", message="annotation")
tags2 = tags1 + [{'name': 'annotated', 'hexsha': gr.get_hexsha()}]
eq_(gr.get_tags(), tags2)
eq_(gr.describe(), tags2[1]['name'])
# compare prev commit
eq_(gr.describe(commitish=first_commit), None)
eq_(gr.describe(commitish=first_commit, tags=True), tags1[0]['name'])