From 4cad8f651765a76ae42467b4341a3e8b0a3bfc81 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Wed, 14 Jan 2015 01:53:19 -0500 Subject: [PATCH] Back to every-builder-is-a-single-repo in the results dir --- lib/gdbgitdb.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/gdbgitdb.py b/lib/gdbgitdb.py index c660bbc..b6ad105 100644 --- a/lib/gdbgitdb.py +++ b/lib/gdbgitdb.py @@ -4,7 +4,7 @@ from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION from buildbot.steps.shell import ShellCommand from sumfiles import get_web_base import os.path -import git +from datetime import datetime class SaveGDBResults (ShellCommand): name = 'save build results' @@ -15,13 +15,14 @@ class SaveGDBResults (ShellCommand): def __init__ (self, **kwargs): ShellCommand.__init__ (self, **kwargs) - def evaluateCommand (self, cmd): + def _evaluateCommand_builder_branch (self, cmd): rev = self.getProperty ('got_revision') builder = self.getProperty ('buildername') istry = self.getProperty ('isTryBuilder') branch = self.getProperty ('branch') repodir = get_web_base () builder_dir = os.path.join (repodir, builder) + # TODO: Include timestamp in the tag name? full_tag = "%s-%s" % (builder, rev) if branch is None: @@ -56,3 +57,40 @@ class SaveGDBResults (ShellCommand): repo.index.write () repo.create_tag (full_tag) return SUCCESS + + def _evaluateCommand_single_repo (self, cmd): + rev = self.getProperty ('got_revision') + builder = self.getProperty ('buildername') + istry = self.getProperty ('isTryBuilder') + branch = self.getProperty ('branch') + repodir = os.path.join (get_web_base (), builder) + full_tag = "%s-%s" % (datetime.now ().strftime ("%Y%m%d-%H%M%S"), rev) + + if branch is None: + branch = 'master' + if istry and istry == 'yes': + # Do nothing + return SUCCESS + + repo = git.Repo.init (path = repodir) + + if 'master' not in repo.heads: + with open (os.path.join (repodir, 'README'), 'w') as f: + f.write ("git repo for GDB test results -- %s" % builder) + repo.index.add (['README']) + repo.index.commit ('Initial commit') + repo.index.write () + + if full_tag not in repo.tags: + repo.index.add (['%s/gdb.sum' % builder, + '%s/gdb.log' % builder, + '%s/%s/baseline' % (builder, branch)]) + if repo.is_dirty (): + repo.index.commit ('Log files for %s' % full_tag) + repo.index.write () + repo.create_tag (full_tag) + return SUCCESS + + def evaluateCommand (self, cmd): + # We can change this scheme for the other one if needed + return self._evaluateCommand_single_repo (cmd)