mirror of
https://github.com/soimort/you-get.git
synced 2025-03-13 03:17:44 +03:00
add util.git
This commit is contained in:
parent
cb9ccc91ab
commit
4fa150f68b
8
src/you_get/util/git.py
Normal file
8
src/you_get/util/git.py
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
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]
|
Loading…
x
Reference in New Issue
Block a user