mirror of
https://github.com/soimort/you-get.git
synced 2025-01-24 05:55:02 +03:00
update util.git
This commit is contained in:
parent
4fa150f68b
commit
e8bf96fc21
@ -4,5 +4,10 @@ import os
|
|||||||
|
|
||||||
def get_head(repo_path):
|
def get_head(repo_path):
|
||||||
"""Get (branch, commit) from HEAD of a git repo."""
|
"""Get (branch, commit) from HEAD of a git repo."""
|
||||||
|
try:
|
||||||
ref = open(os.path.join(repo_path, '.git', 'HEAD'), 'r').read().strip()[5:].split('/')
|
ref = open(os.path.join(repo_path, '.git', 'HEAD'), 'r').read().strip()[5:].split('/')
|
||||||
return ref[-1], open(os.path.join(repo_path, '.git', *ref), 'r').read().strip()[:7]
|
branch = ref[-1]
|
||||||
|
commit = open(os.path.join(repo_path, '.git', *ref), 'r').read().strip()[:7]
|
||||||
|
return branch, commit
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user