Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'devbot/utils.py')
-rw-r--r--devbot/utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/devbot/utils.py b/devbot/utils.py
new file mode 100644
index 0000000..2864948
--- /dev/null
+++ b/devbot/utils.py
@@ -0,0 +1,18 @@
+import os
+import subprocess
+
+devnull = open("/dev/null", "w")
+
+def get_commit_id(dir):
+ orig_cwd = os.getcwd()
+ os.chdir(dir)
+
+ try:
+ commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"],
+ stderr=devnull).strip()
+ except subprocess.CalledProcessError:
+ commit_id = None
+
+ os.chdir(orig_cwd)
+
+ return commit_id