Commits

mattip  committed fedbf76

replace git's parseGotRevision to add something like a revision number

  • Participants
  • Parent commits 9cc6879
  • Branches numpy-tests

Comments (0)

Files changed (2)

File bot2/pypybuildbot/builds.py

 from buildbot.steps.source.mercurial import Mercurial
 from buildbot.steps.source.git import Git
-from buildbot.process.buildstep import BuildStep
+from buildbot.process.buildstep import BuildStep, BuildStepFailed
 from buildbot.process import factory
 from buildbot.steps import shell, transfer
 from buildbot.steps.trigger import Trigger
 from buildbot import locks
 from pypybuildbot.util import symlink_force
 from buildbot.status.results import SKIPPED, SUCCESS
+from twisted.python import log
+from twisted.internet import defer
 import os
 
 # buildbot supports SlaveLocks, which can be used to limit the amout of builds
 # changeset-id for got_revision and final_file_name and sorting the builds
 # chronologically
 
-class UpdateGitCheckout(ShellCmd):
-    description = 'git checkout'
-    command = 'UNKNOWN'
-
-    def __init__(self, workdir=None, haltOnFailure=True, force_branch=None,
-                 **kwargs):
-        ShellCmd.__init__(self, workdir=workdir, haltOnFailure=haltOnFailure,
-                          **kwargs)
-        self.force_branch = force_branch
-        self.addFactoryArguments(force_branch=force_branch)
-
-    def start(self):
-        if self.force_branch is not None:
-            branch = self.force_branch
-            # Note: We could add a warning to the output if we
-            # ignore the branch set by the user.
-        else:
-            properties = self.build.getProperties()
-            branch = properties['branch'] or 'default'
-        command = ["git", "checkout", "-f", branch]
-        self.setCommand(command)
-        ShellCmd.start(self)
-
-
 class CheckGotRevision(ShellCmd):
     description = 'got_revision'
     command = ['hg', 'parents', '--template', 'got_revision:{rev}:{node}']
                 workdir=workdir,
                 logEnviron=False))
 
+class PyPyGit(Git):
+    @defer.inlineCallbacks
+    def parseGotRevision(self, _=None):
+        stdout = yield self._dovccmd(['describe', '--tags', 'HEAD'], collectStdout=True)
+        revision = ':'.join(stdout.strip().split('-')[-2:])
+        log.msg("Got Git revision %s" % (revision, ))
+        self.updateSourceProperty('got_revision', revision)
+        defer.returnValue(0)
+
 def update_git(platform, factory, repourl, workdir, use_branch,
-              force_branch=None):
-    factory.addStep(
-            Git(
+              force_branch='HEAD'):
+    factory.addStep( PyPyGit(
                 repourl=repourl,
                 mode='full',
                 method='fresh',
                 workdir=workdir,
+                branch=force_branch,
                 logEnviron=False))
 
 def setup_steps(platform, factory, workdir=None,

File bot2/pypybuildbot/test/test_builds.py

     translateInst = builds.Translate(['-O0'], ['--no-allworkingmodules'])
 
     assert translateInst.command[-len(expected):] == expected
-    
+
     translateFactory = translateInst._getStepFactory().factory
     args = translateInst._getStepFactory().args
     rebuiltTranslate = translateFactory(*args)
-                
+
     assert rebuiltTranslate.command[-len(expected):] == expected
 
     rebuiltTranslate.build = FakeBuild()
                                                'base-latest'))
 
 class TestPytestCmd(object):
-    
+
     class Fake(object):
         def __init__(self, **kwds):
             self.__dict__.update(kwds)
         summary = builder.summary_by_branch_and_revision[('trunk', '123')]
         assert summary.to_tuple() == (1, 1, 2, 0)
 
-    def test_branch_is_None(self): 
+    def test_branch_is_None(self):
         step, cmd, builder = self._create(log='', rev='123', branch=None)
         step.commandComplete(cmd)
         assert ('trunk', '123') in builder.summary_by_branch_and_revision
         step, cmd, builder = self._create(log='', rev='123', branch='branch/foo/')
         step.commandComplete(cmd)
         assert ('branch/foo', '123') in builder.summary_by_branch_and_revision
-        
+
     def test_multiple_logs(self):
         log = """F a/b.py:test_one
 . a/b.py:test_two