Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/git.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-25 02:34:09 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-25 02:34:09 (GMT)
commit0d0a7194226215703c5536fdae4993a4d4a81816 (patch)
tree10de369d72784edccaab9a34f7eb28911288c9ee /devbot/git.py
parentd450954d31df8d22c96ccd76d6af1d983266a2d4 (diff)
Refactor to put get_commit_id in the git module
Diffstat (limited to 'devbot/git.py')
-rw-r--r--devbot/git.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/devbot/git.py b/devbot/git.py
index 8f6699c..4a86bd6 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -2,6 +2,9 @@ import os
import subprocess
from devbot import command
+from devbot import utils
+
+_root_path = None
def _chdir(func):
def wrapped(*args, **kwargs):
@@ -76,6 +79,17 @@ class Module:
return subprocess.check_output(["git", "diff"])
@_chdir
+ def is_valid(self):
+ result = subprocess.call(["git", "rev-parse", "HEAD"],
+ stdout=utils.devnull,
+ stderr=utils.devnull)
+ return result == 0
+
+ @_chdir
+ def get_commit_id(self):
+ return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
+
+ @_chdir
def get_annotation(self, tag):
# FIXME this is fragile, there must be a better way
@@ -105,3 +119,18 @@ class Module:
command.run(["git", "clean", "-fdx"])
return True
+
+def set_root_path(path):
+ global _root_path
+ _root_path = path
+
+def get_root_module():
+ remote = "git://git.sugarlabs.org/sugar-build/sugar-build.git"
+
+ module = Module(name=os.path.basename(_root_path),
+ remote=remote,
+ path=os.path.dirname(_root_path))
+ if not module.is_valid():
+ return None
+
+ return module