From 39f3d8a9428e031c4bdb0cc9a26f2fb1df9a7520 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Sun, 16 Dec 2012 16:53:36 +0000 Subject: Add a distribute command It builds and uploads releases. --- (limited to 'devbot/git.py') 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) -- cgit v0.9.1