def last_commit(remote=True, short=False):
'''
Get the last commit of the git repository.
Note: This assumes the current working directory (on remote or local host)
to be a git repository. So, make sure current directory is set before using this.
'''
cmd = 'git rev-parse{}HEAD'.format(' --short ' if short else ' ')
with hide('everything'):
result = run(cmd) if remote else local(cmd, capture=True)
return result.strip()
评论列表
文章目录