def get_latest_tag(path,
exec_function=asyncio.create_subprocess_exec):
"""Get the latest tag in path.
Args:
path (str): the path to run ``git describe --abbrev=0`` in.
Returns:
str: the tag name found.
Raises:
ScriptWorkerRetryException: on failure.
"""
proc = await exec_function(
'git', "describe", "--abbrev=0", cwd=path,
stdout=PIPE, stderr=DEVNULL, stdin=DEVNULL, close_fds=True,
)
tag, err = await proc.communicate()
exitcode = await proc.wait()
if exitcode:
raise ScriptWorkerRetryException(
"Can't get tag at {}: {}!".format(path, err)
)
return tag.decode('utf-8').rstrip()
评论列表
文章目录