diff --git a/src/you_get/util/git.py b/src/you_get/util/git.py index 01a8ce17..6891709e 100644 --- a/src/you_get/util/git.py +++ b/src/you_get/util/git.py @@ -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