mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45: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):
|
||||
"""Get (branch, commit) from HEAD of a git repo."""
|
||||
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]
|
||||
try:
|
||||
ref = open(os.path.join(repo_path, '.git', 'HEAD'), 'r').read().strip()[5:].split('/')
|
||||
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