From 4fa150f68b6b314e3ecdbcfe484337e9b46150df Mon Sep 17 00:00:00 2001
From: Mort Yao <mort.yao@gmail.com>
Date: Mon, 21 Jul 2014 00:02:45 +0200
Subject: [PATCH] add util.git

---
 src/you_get/util/git.py | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 src/you_get/util/git.py

diff --git a/src/you_get/util/git.py b/src/you_get/util/git.py
new file mode 100644
index 00000000..01a8ce17
--- /dev/null
+++ b/src/you_get/util/git.py
@@ -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]