def git_info():
head, diff, remote = None, None, None
try:
head = subprocess.getoutput('git rev-parse HEAD').strip()
except subprocess.CalledProcessError:
pass
try:
diff = subprocess.getoutput('git diff --no-color')
except subprocess.CalledProcessError:
pass
try:
remote = subprocess.getoutput('git remote -v').strip()
except subprocess.CalledProcessError:
pass
git_dict = {'head': head or 'Unknown',
'diff': diff or 'Unknown',
'remote': remote or 'Unknown'}
return git_dict
评论列表
文章目录