def version_getter(config):
"""Get tag associated with HEAD; fall back to SHA1.
If HEAD is tagged, return the tag name; otherwise fall back to
HEAD's short SHA1 hash.
.. note:: Only annotated tags are considered.
TODO: Support non-annotated tags?
"""
try:
check_output(['git', 'rev-parse', '--is-inside-work-tree'], stderr=DEVNULL)
except CalledProcessError:
return None
encoding = getpreferredencoding(do_setlocale=False)
try:
version = check_output(['git', 'describe', '--exact-match'], stderr=DEVNULL)
except CalledProcessError:
version = check_output(['git', 'rev-parse', '--short', 'HEAD'])
version = version.decode(encoding).strip()
return version
评论列表
文章目录