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-16 16:53:36 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-16 16:53:36 (GMT)
commit39f3d8a9428e031c4bdb0cc9a26f2fb1df9a7520 (patch)
tree7947f1413318b4379bae8e6c28fc92e61d38d3ee /devbot/git.py
parentc6206d0f80d5961b5d52a5b03765acdad2c22f7e (diff)
Add a distribute command
It builds and uploads releases.
Diffstat (limited to 'devbot/git.py')
-rw-r--r--devbot/git.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/devbot/git.py b/devbot/git.py
index b9008af..1e361f0 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -1,7 +1,20 @@
import os
+import subprocess
from devbot import command
+def _chdir(func):
+ def wrapped(*args, **kwargs):
+ orig_cwd = os.getcwd()
+
+ os.chdir(args[0].local)
+ result = func(*args, **kwargs)
+ os.chdir(orig_cwd)
+
+ return result
+
+ return wrapped
+
class Module:
def __init__(self, path=None, name=None, remote=None,
branch="master", tag=None, retry=10):
@@ -45,6 +58,40 @@ class Module:
command.run(["git", "merge", "--ff-only",
"origin/%s" % self._branch])
+ @_chdir
+ def checkout(self, revision=None):
+ if revision is None:
+ revision = self.tag
+ if revision is None:
+ revision = self._branch
+
+ command.run(["git", "checkout", revision])
+
+ @_chdir
+ def describe(self):
+ return subprocess.check_output(["git", "describe"]).strip()
+
+ @_chdir
+ def get_annotation(self, tag):
+ # FIXME this is fragile, there must be a better way
+
+ show = subprocess.check_output(["git", "show", tag])
+
+ annotation = []
+ for line in show.split("\n"):
+ ignore = False
+ for start in ["tag ", "Tagger: ", "Date: "]:
+ if line.startswith(start):
+ ignore = True
+
+ if line.startswith("commit "):
+ break
+
+ if not ignore:
+ annotation.append(line)
+
+ return "\n".join(annotation)
+
def clean(self):
try:
os.chdir(self.local)