def git_call(cmd, path):
"""Calls a command with check_output, raising NotARepo if there is no git
repo there. This lets us avoid the race condition of a repo disappearing
disappear before we call the command."""
try:
proc = Popen(cmd, cwd=path, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
except OSError:
# Git not installed, or repo path doesn't exist or isn't a directory.
raise NotARepo(proc.returncode, cmd, output=(stdout + stderr))
else:
if proc.returncode:
if 'Not a git repository' in stderr.decode('utf8'):
raise NotARepo(proc.returncode, cmd, output=(stdout + stderr))
else:
raise CalledProcessError(proc.returncode, cmd, output=(stdout + stderr))
return stdout.decode('utf8')
git-nautilus-icons.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录