+def git_revision():
+ if not os.path.exists('.git'):
+ return None
+
+ cmd = "LANG= git log --abbrev HEAD^..HEAD ."
+ output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
+ o = output[0].decode('utf-8')
+ return o.replace("commit ", "")[0:10]
+