def active_git_branch(path):
try:
repo = git.Repo(path)
except git.exc.NoSuchPathError as error:
return None
if not repo.working_tree_dir:
return None
rval = repo.active_branch
if not rval:
return None
rval = str(rval)
return rval
评论列表
文章目录