"Fossies" - the Fresh Open Source Software Archive

Member "buildbot-2.3.1/buildbot/test/unit/test_steps_source_git.py" (23 May 2019, 167022 Bytes) of package /linux/misc/buildbot-2.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "test_steps_source_git.py": 2.2.0_vs_2.3.0.

    1 # This file is part of Buildbot.  Buildbot is free software: you can
    2 # redistribute it and/or modify it under the terms of the GNU General Public
    3 # License as published by the Free Software Foundation, version 2.
    4 #
    5 # This program is distributed in the hope that it will be useful, but WITHOUT
    6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8 # details.
    9 #
   10 # You should have received a copy of the GNU General Public License along with
   11 # this program; if not, write to the Free Software Foundation, Inc., 51
   12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   13 #
   14 # Copyright Buildbot Team Members
   15 
   16 from parameterized import parameterized
   17 
   18 from twisted.internet import defer
   19 from twisted.internet import error
   20 from twisted.trial import unittest
   21 
   22 from buildbot import config as bbconfig
   23 from buildbot.interfaces import WorkerTooOldError
   24 from buildbot.process import remotetransfer
   25 from buildbot.process.results import EXCEPTION
   26 from buildbot.process.results import FAILURE
   27 from buildbot.process.results import RETRY
   28 from buildbot.process.results import SUCCESS
   29 from buildbot.steps.source import git
   30 from buildbot.test.fake.remotecommand import Expect
   31 from buildbot.test.fake.remotecommand import ExpectRemoteRef
   32 from buildbot.test.fake.remotecommand import ExpectShell
   33 from buildbot.test.util import config
   34 from buildbot.test.util import sourcesteps
   35 from buildbot.test.util import steps
   36 from buildbot.test.util.misc import TestReactorMixin
   37 
   38 
   39 class TestGit(sourcesteps.SourceStepMixin,
   40               config.ConfigErrorsMixin,
   41               TestReactorMixin,
   42               unittest.TestCase):
   43 
   44     stepClass = git.Git
   45 
   46     def setUp(self):
   47         self.setUpTestReactor()
   48         self.sourceName = self.stepClass.__name__
   49         return self.setUpSourceStep()
   50 
   51     def tearDown(self):
   52         return self.tearDownSourceStep()
   53 
   54     def test_mode_full_clean(self):
   55         self.setupStep(
   56             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
   57                            mode='full', method='clean'))
   58         self.expectCommands(
   59             ExpectShell(workdir='wkdir',
   60                         command=['git', '--version'])
   61             + ExpectShell.log('stdio',
   62                               stdout='git version 1.7.5')
   63             + 0,
   64             Expect('stat', dict(file='wkdir/.buildbot-patched',
   65                                 logEnviron=True))
   66             + 1,
   67             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
   68                                'timeout': 1200})
   69             + Expect.update('files', ['.git'])
   70             + 0,
   71             ExpectShell(workdir='wkdir',
   72                         command=['git', 'clean', '-f', '-f', '-d'])
   73             + 0,
   74             ExpectShell(workdir='wkdir',
   75                         command=['git', 'fetch', '-t',
   76                                  'http://github.com/buildbot/buildbot.git',
   77                                  'HEAD'])
   78             + 0,
   79             ExpectShell(workdir='wkdir',
   80                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
   81             + 0,
   82             ExpectShell(workdir='wkdir',
   83                         command=['git', 'rev-parse', 'HEAD'])
   84             + ExpectShell.log('stdio',
   85                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
   86             + 0,
   87         )
   88         self.expectOutcome(result=SUCCESS)
   89         self.expectProperty(
   90             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
   91         return self.runStep()
   92 
   93     def test_mode_full_clean_ssh_key_2_10(self):
   94         self.setupStep(
   95             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
   96                            mode='full', method='clean', sshPrivateKey='sshkey'))
   97 
   98         ssh_workdir = '/wrk/.wkdir.buildbot'
   99         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
  100         ssh_command_config = \
  101             'core.sshCommand=ssh -i "{0}"'.format(ssh_key_path)
  102 
  103         self.expectCommands(
  104             ExpectShell(workdir='wkdir',
  105                         command=['git', '--version'])
  106             + ExpectShell.log('stdio',
  107                               stdout='git version 2.10.0')
  108             + 0,
  109             Expect('stat', dict(file='wkdir/.buildbot-patched',
  110                                 logEnviron=True))
  111             + 1,
  112             Expect('mkdir', dict(dir=ssh_workdir,
  113                                  logEnviron=True))
  114             + 0,
  115             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  116                                         reader=ExpectRemoteRef(
  117                                             remotetransfer.StringFileReader),
  118                                         workerdest=ssh_key_path,
  119                                         workdir='wkdir',
  120                                         mode=0o400))
  121             + 0,
  122             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  123                                'timeout': 1200})
  124             + Expect.update('files', ['.git'])
  125             + 0,
  126             ExpectShell(workdir='wkdir',
  127                         command=['git', 'clean', '-f', '-f', '-d'])
  128             + 0,
  129             ExpectShell(workdir='wkdir',
  130                         command=['git', '-c', ssh_command_config,
  131                                  'fetch', '-t',
  132                                  'http://github.com/buildbot/buildbot.git',
  133                                  'HEAD'])
  134             + 0,
  135             ExpectShell(workdir='wkdir',
  136                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  137             + 0,
  138             ExpectShell(workdir='wkdir',
  139                         command=['git', 'rev-parse', 'HEAD'])
  140             + ExpectShell.log('stdio',
  141                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  142             + 0,
  143             Expect('rmdir', dict(dir=ssh_workdir,
  144                                  logEnviron=True))
  145             + 0,
  146         )
  147         self.expectOutcome(result=SUCCESS)
  148         self.expectProperty(
  149             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  150         return self.runStep()
  151 
  152     def test_mode_full_clean_ssh_key_2_3(self):
  153         self.setupStep(
  154             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  155                            mode='full', method='clean', sshPrivateKey='sshkey'))
  156 
  157         ssh_workdir = '/wrk/.wkdir.buildbot'
  158         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
  159         ssh_command = 'ssh -i "{0}"'.format(ssh_key_path)
  160 
  161         self.expectCommands(
  162             ExpectShell(workdir='wkdir',
  163                         command=['git', '--version'])
  164             + ExpectShell.log('stdio',
  165                               stdout='git version 2.3.0')
  166             + 0,
  167             Expect('stat', dict(file='wkdir/.buildbot-patched',
  168                                 logEnviron=True))
  169             + 1,
  170             Expect('mkdir', dict(dir=ssh_workdir,
  171                                  logEnviron=True))
  172             + 0,
  173             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  174                                         reader=ExpectRemoteRef(
  175                                             remotetransfer.StringFileReader),
  176                                         workerdest=ssh_key_path,
  177                                         workdir='wkdir',
  178                                         mode=0o400))
  179             + 0,
  180             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  181                                'timeout': 1200})
  182             + Expect.update('files', ['.git'])
  183             + 0,
  184             ExpectShell(workdir='wkdir',
  185                         command=['git', 'clean', '-f', '-f', '-d'])
  186             + 0,
  187             ExpectShell(workdir='wkdir',
  188                         command=['git', 'fetch', '-t',
  189                                  'http://github.com/buildbot/buildbot.git',
  190                                  'HEAD'],
  191                         env={'GIT_SSH_COMMAND': ssh_command})
  192             + 0,
  193             ExpectShell(workdir='wkdir',
  194                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  195             + 0,
  196             ExpectShell(workdir='wkdir',
  197                         command=['git', 'rev-parse', 'HEAD'])
  198             + ExpectShell.log('stdio',
  199                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  200             + 0,
  201             Expect('rmdir', dict(dir=ssh_workdir,
  202                                  logEnviron=True))
  203             + 0,
  204         )
  205         self.expectOutcome(result=SUCCESS)
  206         self.expectProperty(
  207             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  208         return self.runStep()
  209 
  210     def test_mode_full_clean_ssh_key_1_7(self):
  211         self.setupStep(
  212             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  213                            mode='full', method='clean', sshPrivateKey='sshkey'))
  214 
  215         ssh_workdir = '/wrk/.wkdir.buildbot'
  216         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
  217         ssh_wrapper_path = '/wrk/.wkdir.buildbot/ssh-wrapper.sh'
  218 
  219         self.expectCommands(
  220             ExpectShell(workdir='wkdir',
  221                         command=['git', '--version'])
  222             + ExpectShell.log('stdio',
  223                               stdout='git version 1.7.0')
  224             + 0,
  225             Expect('stat', dict(file='wkdir/.buildbot-patched',
  226                                 logEnviron=True))
  227             + 1,
  228             Expect('mkdir', dict(dir=ssh_workdir,
  229                                  logEnviron=True))
  230             + 0,
  231             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  232                                         reader=ExpectRemoteRef(
  233                                             remotetransfer.StringFileReader),
  234                                         workerdest=ssh_wrapper_path,
  235                                         workdir='wkdir',
  236                                         mode=0o700))
  237             + 0,
  238             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  239                                         reader=ExpectRemoteRef(
  240                                             remotetransfer.StringFileReader),
  241                                         workerdest=ssh_key_path,
  242                                         workdir='wkdir',
  243                                         mode=0o400))
  244             + 0,
  245             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  246                                'timeout': 1200})
  247             + Expect.update('files', ['.git'])
  248             + 0,
  249             ExpectShell(workdir='wkdir',
  250                         command=['git', 'clean', '-f', '-f', '-d'])
  251             + 0,
  252             ExpectShell(workdir='wkdir',
  253                         command=['git', 'fetch', '-t',
  254                                  'http://github.com/buildbot/buildbot.git',
  255                                  'HEAD'],
  256                         env={'GIT_SSH': ssh_wrapper_path})
  257             + 0,
  258             ExpectShell(workdir='wkdir',
  259                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  260             + 0,
  261             ExpectShell(workdir='wkdir',
  262                         command=['git', 'rev-parse', 'HEAD'])
  263             + ExpectShell.log('stdio',
  264                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  265             + 0,
  266             Expect('rmdir', dict(dir=ssh_workdir,
  267                                  logEnviron=True))
  268             + 0,
  269         )
  270         self.expectOutcome(result=SUCCESS)
  271         self.expectProperty(
  272             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  273         return self.runStep()
  274 
  275     @parameterized.expand([
  276         ('host_key', dict(sshHostKey='sshhostkey')),
  277         ('known_hosts', dict(sshKnownHosts='known_hosts')),
  278     ])
  279     def test_mode_full_clean_ssh_host_key_2_10(self, name, class_params):
  280         self.setupStep(
  281             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  282                            mode='full', method='clean', sshPrivateKey='sshkey', **class_params))
  283 
  284         ssh_workdir = '/wrk/.wkdir.buildbot'
  285         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
  286         ssh_known_hosts_path = '/wrk/.wkdir.buildbot/ssh-known-hosts'
  287         ssh_command_config = \
  288             'core.sshCommand=ssh -i "{0}" ' \
  289             '-o "UserKnownHostsFile={1}"'.format(ssh_key_path,
  290                                                  ssh_known_hosts_path)
  291 
  292         self.expectCommands(
  293             ExpectShell(workdir='wkdir',
  294                         command=['git', '--version'])
  295             + ExpectShell.log('stdio',
  296                               stdout='git version 2.10.0')
  297             + 0,
  298             Expect('stat', dict(file='wkdir/.buildbot-patched',
  299                                 logEnviron=True))
  300             + 1,
  301             Expect('mkdir', dict(dir=ssh_workdir,
  302                                  logEnviron=True))
  303             + 0,
  304             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  305                                         reader=ExpectRemoteRef(
  306                                             remotetransfer.StringFileReader),
  307                                         workerdest=ssh_key_path,
  308                                         workdir='wkdir',
  309                                         mode=0o400))
  310             + 0,
  311             Expect('downloadFile',
  312                    dict(blocksize=32768, maxsize=None,
  313                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
  314                         workerdest=ssh_known_hosts_path,
  315                         workdir='wkdir',
  316                         mode=0o400))
  317             + 0,
  318             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  319                                'timeout': 1200})
  320             + Expect.update('files', ['.git'])
  321             + 0,
  322             ExpectShell(workdir='wkdir',
  323                         command=['git', 'clean', '-f', '-f', '-d'])
  324             + 0,
  325             ExpectShell(workdir='wkdir',
  326                         command=['git', '-c', ssh_command_config,
  327                                  'fetch', '-t',
  328                                  'http://github.com/buildbot/buildbot.git',
  329                                  'HEAD'])
  330             + 0,
  331             ExpectShell(workdir='wkdir',
  332                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  333             + 0,
  334             ExpectShell(workdir='wkdir',
  335                         command=['git', 'rev-parse', 'HEAD'])
  336             + ExpectShell.log('stdio',
  337                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  338             + 0,
  339             Expect('rmdir', dict(dir=ssh_workdir,
  340                                  logEnviron=True))
  341             + 0,
  342         )
  343         self.expectOutcome(result=SUCCESS)
  344         self.expectProperty(
  345             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  346         return self.runStep()
  347 
  348     def test_mode_full_clean_ssh_host_key_2_3(self):
  349         self.setupStep(
  350             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  351                            mode='full', method='clean', sshPrivateKey='sshkey',
  352                            sshHostKey='sshhostkey'))
  353 
  354         ssh_workdir = '/wrk/.wkdir.buildbot'
  355         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
  356         ssh_known_hosts_path = '/wrk/.wkdir.buildbot/ssh-known-hosts'
  357         ssh_command = \
  358             'ssh -i "{0}" ' \
  359             '-o "UserKnownHostsFile={1}"'.format(ssh_key_path,
  360                                                  ssh_known_hosts_path)
  361 
  362         self.expectCommands(
  363             ExpectShell(workdir='wkdir',
  364                         command=['git', '--version'])
  365             + ExpectShell.log('stdio',
  366                               stdout='git version 2.3.0')
  367             + 0,
  368             Expect('stat', dict(file='wkdir/.buildbot-patched',
  369                                 logEnviron=True))
  370             + 1,
  371             Expect('mkdir', dict(dir=ssh_workdir,
  372                                  logEnviron=True))
  373             + 0,
  374             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  375                                         reader=ExpectRemoteRef(
  376                                             remotetransfer.StringFileReader),
  377                                         workerdest=ssh_key_path,
  378                                         workdir='wkdir',
  379                                         mode=0o400))
  380             + 0,
  381             Expect('downloadFile',
  382                    dict(blocksize=32768, maxsize=None,
  383                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
  384                         workerdest=ssh_known_hosts_path,
  385                         workdir='wkdir',
  386                         mode=0o400))
  387             + 0,
  388             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  389                                'timeout': 1200})
  390             + Expect.update('files', ['.git'])
  391             + 0,
  392             ExpectShell(workdir='wkdir',
  393                         command=['git', 'clean', '-f', '-f', '-d'])
  394             + 0,
  395             ExpectShell(workdir='wkdir',
  396                         command=['git', 'fetch', '-t',
  397                                  'http://github.com/buildbot/buildbot.git',
  398                                  'HEAD'],
  399                         env={'GIT_SSH_COMMAND': ssh_command})
  400             + 0,
  401             ExpectShell(workdir='wkdir',
  402                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  403             + 0,
  404             ExpectShell(workdir='wkdir',
  405                         command=['git', 'rev-parse', 'HEAD'])
  406             + ExpectShell.log('stdio',
  407                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  408             + 0,
  409             Expect('rmdir', dict(dir=ssh_workdir,
  410                                  logEnviron=True))
  411             + 0,
  412         )
  413         self.expectOutcome(result=SUCCESS)
  414         self.expectProperty(
  415             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  416         return self.runStep()
  417 
  418     def test_mode_full_clean_ssh_host_key_1_7(self):
  419         self.setupStep(
  420             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  421                            mode='full', method='clean', sshPrivateKey='sshkey',
  422                            sshHostKey='sshhostkey'))
  423 
  424         ssh_workdir = '/wrk/.wkdir.buildbot'
  425         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
  426         ssh_wrapper_path = '/wrk/.wkdir.buildbot/ssh-wrapper.sh'
  427         ssh_known_hosts_path = '/wrk/.wkdir.buildbot/ssh-known-hosts'
  428 
  429         self.expectCommands(
  430             ExpectShell(workdir='wkdir',
  431                         command=['git', '--version'])
  432             + ExpectShell.log('stdio',
  433                               stdout='git version 1.7.0')
  434             + 0,
  435             Expect('stat', dict(file='wkdir/.buildbot-patched',
  436                                 logEnviron=True))
  437             + 1,
  438             Expect('mkdir', dict(dir=ssh_workdir,
  439                                  logEnviron=True))
  440             + 0,
  441             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  442                                         reader=ExpectRemoteRef(
  443                                             remotetransfer.StringFileReader),
  444                                         workerdest=ssh_wrapper_path,
  445                                         workdir='wkdir',
  446                                         mode=0o700))
  447             + 0,
  448             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  449                                         reader=ExpectRemoteRef(
  450                                             remotetransfer.StringFileReader),
  451                                         workerdest=ssh_key_path,
  452                                         workdir='wkdir',
  453                                         mode=0o400))
  454             + 0,
  455             Expect('downloadFile',
  456                    dict(blocksize=32768, maxsize=None,
  457                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
  458                         workerdest=ssh_known_hosts_path,
  459                         workdir='wkdir',
  460                         mode=0o400))
  461             + 0,
  462             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  463                                'timeout': 1200})
  464             + Expect.update('files', ['.git'])
  465             + 0,
  466             ExpectShell(workdir='wkdir',
  467                         command=['git', 'clean', '-f', '-f', '-d'])
  468             + 0,
  469             ExpectShell(workdir='wkdir',
  470                         command=['git', 'fetch', '-t',
  471                                  'http://github.com/buildbot/buildbot.git',
  472                                  'HEAD'],
  473                         env={'GIT_SSH': ssh_wrapper_path})
  474             + 0,
  475             ExpectShell(workdir='wkdir',
  476                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  477             + 0,
  478             ExpectShell(workdir='wkdir',
  479                         command=['git', 'rev-parse', 'HEAD'])
  480             + ExpectShell.log('stdio',
  481                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  482             + 0,
  483             Expect('rmdir', dict(dir=ssh_workdir,
  484                                  logEnviron=True))
  485             + 0,
  486         )
  487         self.expectOutcome(result=SUCCESS)
  488         self.expectProperty(
  489             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  490         return self.runStep()
  491 
  492     def test_mode_full_clean_ssh_host_key_2_10_abs_workdir(self):
  493         self.setupStep(
  494             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  495                            mode='full', method='clean', sshPrivateKey='sshkey',
  496                            sshHostKey='sshhostkey'),
  497             wantDefaultWorkdir=False)
  498         workdir = '/myworkdir/workdir'
  499         self.build.workdir = workdir
  500 
  501         ssh_workdir = '/myworkdir/.workdir.buildbot'
  502         ssh_key_path = '/myworkdir/.workdir.buildbot/ssh-key'
  503         ssh_known_hosts_path = '/myworkdir/.workdir.buildbot/ssh-known-hosts'
  504         ssh_command_config = \
  505             'core.sshCommand=ssh -i "{0}" ' \
  506             '-o "UserKnownHostsFile={1}"'.format(ssh_key_path,
  507                                                  ssh_known_hosts_path)
  508 
  509         self.expectCommands(
  510             ExpectShell(workdir=workdir,
  511                         command=['git', '--version'])
  512             + ExpectShell.log('stdio',
  513                               stdout='git version 2.10.0')
  514             + 0,
  515             Expect('stat', dict(file='/myworkdir/workdir/.buildbot-patched',
  516                                 logEnviron=True))
  517             + 1,
  518             Expect('mkdir', dict(dir=ssh_workdir,
  519                                  logEnviron=True))
  520             + 0,
  521             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  522                                         reader=ExpectRemoteRef(
  523                                             remotetransfer.StringFileReader),
  524                                         workerdest=ssh_key_path,
  525                                         workdir=workdir,
  526                                         mode=0o400))
  527             + 0,
  528             Expect('downloadFile',
  529                    dict(blocksize=32768, maxsize=None,
  530                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
  531                         workerdest=ssh_known_hosts_path,
  532                         workdir=workdir,
  533                         mode=0o400))
  534             + 0,
  535             Expect('listdir', {'dir': workdir, 'logEnviron': True,
  536                                'timeout': 1200})
  537             + Expect.update('files', ['.git'])
  538             + 0,
  539             ExpectShell(workdir=workdir,
  540                         command=['git', 'clean', '-f', '-f', '-d'])
  541             + 0,
  542             ExpectShell(workdir=workdir,
  543                         command=['git', '-c', ssh_command_config,
  544                                  'fetch', '-t',
  545                                  'http://github.com/buildbot/buildbot.git',
  546                                  'HEAD'])
  547             + 0,
  548             ExpectShell(workdir=workdir,
  549                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  550             + 0,
  551             ExpectShell(workdir=workdir,
  552                         command=['git', 'rev-parse', 'HEAD'])
  553             + ExpectShell.log('stdio',
  554                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  555             + 0,
  556             Expect('rmdir', dict(dir=ssh_workdir,
  557                                  logEnviron=True))
  558             + 0,
  559         )
  560         self.expectOutcome(result=SUCCESS)
  561         self.expectProperty(
  562             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  563         return self.runStep()
  564 
  565     def test_mode_full_clean_win32path(self):
  566         self.setupStep(
  567             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  568                            mode='full', method='clean'))
  569         self.changeWorkerSystem('win32')
  570         self.expectCommands(
  571             ExpectShell(workdir='wkdir',
  572                         command=['git', '--version'])
  573             + ExpectShell.log('stdio',
  574                               stdout='git version 1.7.5')
  575             + 0,
  576             Expect('stat', dict(file=r'wkdir\.buildbot-patched',
  577                                 logEnviron=True))
  578             + 1,
  579             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  580                                'timeout': 1200})
  581             + Expect.update('files', ['.git'])
  582             + 0,
  583             ExpectShell(workdir='wkdir',
  584                         command=['git', 'clean', '-f', '-f', '-d'])
  585             + 0,
  586             ExpectShell(workdir='wkdir',
  587                         command=['git', 'fetch', '-t',
  588                                  'http://github.com/buildbot/buildbot.git',
  589                                  'HEAD'])
  590             + 0,
  591             ExpectShell(workdir='wkdir',
  592                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  593             + 0,
  594             ExpectShell(workdir='wkdir',
  595                         command=['git', 'rev-parse', 'HEAD'])
  596             + ExpectShell.log('stdio',
  597                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  598             + 0,
  599         )
  600         self.expectOutcome(result=SUCCESS)
  601         self.expectProperty(
  602             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  603         return self.runStep()
  604 
  605     def test_mode_full_clean_win32path_ssh_key_2_10(self):
  606         self.setupStep(
  607             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  608                            mode='full', method='clean', sshPrivateKey='sshkey'))
  609         self.changeWorkerSystem('win32')
  610 
  611         ssh_workdir = '\\wrk\\.wkdir.buildbot'
  612         ssh_key_path = '\\wrk\\.wkdir.buildbot\\ssh-key'
  613         ssh_command_config = 'core.sshCommand=ssh -i "{0}"'.format(ssh_key_path)
  614 
  615         self.expectCommands(
  616             ExpectShell(workdir='wkdir',
  617                         command=['git', '--version'])
  618             + ExpectShell.log('stdio',
  619                               stdout='git version 2.10.0')
  620             + 0,
  621             Expect('stat', dict(file='wkdir\\.buildbot-patched',
  622                                 logEnviron=True))
  623             + 1,
  624             Expect('mkdir', dict(dir=ssh_workdir,
  625                                  logEnviron=True))
  626             + 0,
  627             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  628                                         reader=ExpectRemoteRef(
  629                                             remotetransfer.StringFileReader),
  630                                         workerdest=ssh_key_path,
  631                                         workdir='wkdir',
  632                                         mode=0o400))
  633             + 0,
  634             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  635                                'timeout': 1200})
  636             + Expect.update('files', ['.git'])
  637             + 0,
  638             ExpectShell(workdir='wkdir',
  639                         command=['git', 'clean', '-f', '-f', '-d'])
  640             + 0,
  641             ExpectShell(workdir='wkdir',
  642                         command=['git', '-c', ssh_command_config,
  643                                  'fetch', '-t',
  644                                  'http://github.com/buildbot/buildbot.git',
  645                                  'HEAD'])
  646             + 0,
  647             ExpectShell(workdir='wkdir',
  648                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  649             + 0,
  650             ExpectShell(workdir='wkdir',
  651                         command=['git', 'rev-parse', 'HEAD'])
  652             + ExpectShell.log('stdio',
  653                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  654             + 0,
  655             Expect('rmdir', dict(dir=ssh_workdir,
  656                                  logEnviron=True))
  657             + 0,
  658         )
  659         self.expectOutcome(result=SUCCESS)
  660         self.expectProperty(
  661             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  662         return self.runStep()
  663 
  664     def test_mode_full_clean_win32path_ssh_key_2_3(self):
  665         self.setupStep(
  666             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  667                            mode='full', method='clean', sshPrivateKey='sshkey'))
  668         self.changeWorkerSystem('win32')
  669 
  670         ssh_workdir = '\\wrk\\.wkdir.buildbot'
  671         ssh_key_path = '\\wrk\\.wkdir.buildbot\\ssh-key'
  672         ssh_command = 'ssh -i "{0}"'.format(ssh_key_path)
  673 
  674         self.expectCommands(
  675             ExpectShell(workdir='wkdir',
  676                         command=['git', '--version'])
  677             + ExpectShell.log('stdio',
  678                               stdout='git version 2.3.0')
  679             + 0,
  680             Expect('stat', dict(file='wkdir\\.buildbot-patched',
  681                                 logEnviron=True))
  682             + 1,
  683             Expect('mkdir', dict(dir=ssh_workdir,
  684                                  logEnviron=True))
  685             + 0,
  686             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  687                                         reader=ExpectRemoteRef(
  688                                             remotetransfer.StringFileReader),
  689                                         workerdest=ssh_key_path,
  690                                         workdir='wkdir',
  691                                         mode=0o400))
  692             + 0,
  693             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  694                                'timeout': 1200})
  695             + Expect.update('files', ['.git'])
  696             + 0,
  697             ExpectShell(workdir='wkdir',
  698                         command=['git', 'clean', '-f', '-f', '-d'])
  699             + 0,
  700             ExpectShell(workdir='wkdir',
  701                         command=['git', 'fetch', '-t',
  702                                  'http://github.com/buildbot/buildbot.git',
  703                                  'HEAD'],
  704                         env={'GIT_SSH_COMMAND': ssh_command})
  705             + 0,
  706             ExpectShell(workdir='wkdir',
  707                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  708             + 0,
  709             ExpectShell(workdir='wkdir',
  710                         command=['git', 'rev-parse', 'HEAD'])
  711             + ExpectShell.log('stdio',
  712                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  713             + 0,
  714             Expect('rmdir', dict(dir=ssh_workdir,
  715                                  logEnviron=True))
  716             + 0,
  717         )
  718         self.expectOutcome(result=SUCCESS)
  719         self.expectProperty(
  720             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  721         return self.runStep()
  722 
  723     def test_mode_full_clean_win32path_ssh_key_1_7(self):
  724         self.setupStep(
  725             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  726                            mode='full', method='clean', sshPrivateKey='sshkey'))
  727         self.changeWorkerSystem('win32')
  728 
  729         ssh_workdir = '\\wrk\\.wkdir.buildbot'
  730         ssh_key_path = '\\wrk\\.wkdir.buildbot\\ssh-key'
  731         ssh_wrapper_path = '\\wrk\\.wkdir.buildbot\\ssh-wrapper.sh'
  732 
  733         self.expectCommands(
  734             ExpectShell(workdir='wkdir',
  735                         command=['git', '--version'])
  736             + ExpectShell.log('stdio',
  737                               stdout='git version 1.7.0')
  738             + 0,
  739             Expect('stat', dict(file='wkdir\\.buildbot-patched',
  740                                 logEnviron=True))
  741             + 1,
  742             Expect('mkdir', dict(dir=ssh_workdir,
  743                                  logEnviron=True))
  744             + 0,
  745             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  746                                         reader=ExpectRemoteRef(
  747                                             remotetransfer.StringFileReader),
  748                                         workerdest=ssh_wrapper_path,
  749                                         workdir='wkdir',
  750                                         mode=0o700))
  751             + 0,
  752             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  753                                         reader=ExpectRemoteRef(
  754                                             remotetransfer.StringFileReader),
  755                                         workerdest=ssh_key_path,
  756                                         workdir='wkdir',
  757                                         mode=0o400))
  758             + 0,
  759             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  760                                'timeout': 1200})
  761             + Expect.update('files', ['.git'])
  762             + 0,
  763             ExpectShell(workdir='wkdir',
  764                         command=['git', 'clean', '-f', '-f', '-d'])
  765             + 0,
  766             ExpectShell(workdir='wkdir',
  767                         command=['git', 'fetch', '-t',
  768                                  'http://github.com/buildbot/buildbot.git',
  769                                  'HEAD'],
  770                         env={'GIT_SSH': ssh_wrapper_path})
  771             + 0,
  772             ExpectShell(workdir='wkdir',
  773                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  774             + 0,
  775             ExpectShell(workdir='wkdir',
  776                         command=['git', 'rev-parse', 'HEAD'])
  777             + ExpectShell.log('stdio',
  778                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  779             + 0,
  780             Expect('rmdir', dict(dir=ssh_workdir,
  781                                  logEnviron=True))
  782             + 0,
  783         )
  784         self.expectOutcome(result=SUCCESS)
  785         self.expectProperty(
  786             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  787         return self.runStep()
  788 
  789     def test_mode_full_clean_timeout(self):
  790         self.setupStep(
  791             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  792                            timeout=1,
  793                            mode='full', method='clean'))
  794         self.expectCommands(
  795             ExpectShell(workdir='wkdir',
  796                         timeout=1,
  797                         command=['git', '--version'])
  798             + ExpectShell.log('stdio',
  799                               stdout='git version 1.7.5')
  800             + 0,
  801             Expect('stat', dict(file='wkdir/.buildbot-patched',
  802                                 logEnviron=True))
  803             + 1,
  804             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  805                                'timeout': 1})
  806             + Expect.update('files', ['.git'])
  807             + 0,
  808             ExpectShell(workdir='wkdir',
  809                         timeout=1,
  810                         command=['git', 'clean', '-f', '-f', '-d'])
  811             + 0,
  812             ExpectShell(workdir='wkdir',
  813                         timeout=1,
  814                         command=['git', 'fetch', '-t',
  815                                  'http://github.com/buildbot/buildbot.git',
  816                                  'HEAD'])
  817             + 0,
  818             ExpectShell(workdir='wkdir',
  819                         timeout=1,
  820                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  821             + 0,
  822             ExpectShell(workdir='wkdir',
  823                         timeout=1,
  824                         command=['git', 'rev-parse', 'HEAD'])
  825             + ExpectShell.log('stdio',
  826                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  827             + 0,
  828         )
  829         self.expectOutcome(result=SUCCESS)
  830         self.expectProperty(
  831             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  832         return self.runStep()
  833 
  834     def test_mode_full_clean_patch(self):
  835         self.setupStep(
  836             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  837                            mode='full', method='clean'),
  838             patch=(1, 'patch'))
  839         self.expectCommands(
  840             ExpectShell(workdir='wkdir',
  841                         command=['git', '--version'])
  842             + ExpectShell.log('stdio',
  843                               stdout='git version 1.7.5')
  844             + 0,
  845             Expect('stat', dict(file='wkdir/.buildbot-patched',
  846                                 logEnviron=True))
  847             + 0,
  848             ExpectShell(workdir='wkdir',
  849                         command=['git', 'clean', '-f', '-f', '-d', '-x'],
  850                         logEnviron=True)
  851             + 0,
  852             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  853                                'timeout': 1200})
  854             + Expect.update('files', ['.git'])
  855             + 0,
  856             ExpectShell(workdir='wkdir',
  857                         command=['git', 'clean', '-f', '-f', '-d'])
  858             + 0,
  859             ExpectShell(workdir='wkdir',
  860                         command=['git', 'fetch', '-t',
  861                                  'http://github.com/buildbot/buildbot.git',
  862                                  'HEAD'])
  863             + 0,
  864             ExpectShell(workdir='wkdir',
  865                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  866             + 0,
  867             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  868                                         reader=ExpectRemoteRef(
  869                                             remotetransfer.StringFileReader),
  870                                         workerdest='.buildbot-diff', workdir='wkdir',
  871                                         mode=None))
  872             + 0,
  873             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  874                                         reader=ExpectRemoteRef(
  875                                             remotetransfer.StringFileReader),
  876                                         workerdest='.buildbot-patched', workdir='wkdir',
  877                                         mode=None))
  878             + 0,
  879             ExpectShell(workdir='wkdir',
  880                         command=['git', 'update-index', '--refresh'])
  881             + 0,
  882             ExpectShell(workdir='wkdir',
  883                         command=['git', 'apply', '--index', '-p', '1'],
  884                         initialStdin='patch')
  885             + 0,
  886             Expect('rmdir', dict(dir='wkdir/.buildbot-diff',
  887                                  logEnviron=True))
  888             + 0,
  889             ExpectShell(workdir='wkdir',
  890                         command=['git', 'rev-parse', 'HEAD'])
  891             + ExpectShell.log('stdio',
  892                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  893             + 0,
  894         )
  895         self.expectOutcome(result=SUCCESS)
  896         self.expectProperty(
  897             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  898         return self.runStep()
  899 
  900     def test_mode_full_clean_patch_worker_2_16(self):
  901         self.setupStep(
  902             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  903                            mode='full', method='clean'),
  904             patch=(1, 'patch'),
  905             worker_version={'*': '2.16'})
  906         self.expectCommands(
  907             ExpectShell(workdir='wkdir',
  908                         command=['git', '--version'])
  909             + ExpectShell.log('stdio',
  910                               stdout='git version 1.7.5')
  911             + 0,
  912             Expect('stat', dict(file='wkdir/.buildbot-patched',
  913                                 logEnviron=True))
  914             + 0,
  915             ExpectShell(workdir='wkdir',
  916                         command=['git', 'clean', '-f', '-f', '-d', '-x'],
  917                         logEnviron=True)
  918             + 0,
  919             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  920                                'timeout': 1200})
  921             + Expect.update('files', ['.git'])
  922             + 0,
  923             ExpectShell(workdir='wkdir',
  924                         command=['git', 'clean', '-f', '-f', '-d'])
  925             + 0,
  926             ExpectShell(workdir='wkdir',
  927                         command=['git', 'fetch', '-t',
  928                                  'http://github.com/buildbot/buildbot.git',
  929                                  'HEAD'])
  930             + 0,
  931             ExpectShell(workdir='wkdir',
  932                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  933             + 0,
  934             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  935                                         reader=ExpectRemoteRef(
  936                                             remotetransfer.StringFileReader),
  937                                         slavedest='.buildbot-diff', workdir='wkdir',
  938                                         mode=None))
  939             + 0,
  940             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  941                                         reader=ExpectRemoteRef(
  942                                             remotetransfer.StringFileReader),
  943                                         slavedest='.buildbot-patched', workdir='wkdir',
  944                                         mode=None))
  945             + 0,
  946             ExpectShell(workdir='wkdir',
  947                         command=['git', 'update-index', '--refresh'])
  948             + 0,
  949             ExpectShell(workdir='wkdir',
  950                         command=['git', 'apply', '--index', '-p', '1'],
  951                         initialStdin='patch')
  952             + 0,
  953             Expect('rmdir', dict(dir='wkdir/.buildbot-diff',
  954                                  logEnviron=True))
  955             + 0,
  956             ExpectShell(workdir='wkdir',
  957                         command=['git', 'rev-parse', 'HEAD'])
  958             + ExpectShell.log('stdio',
  959                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  960             + 0,
  961         )
  962         self.expectOutcome(result=SUCCESS)
  963         self.expectProperty(
  964             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
  965         return self.runStep()
  966 
  967     def test_mode_full_clean_patch_fail(self):
  968         self.setupStep(
  969             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
  970                            mode='full', method='clean'),
  971             patch=(1, 'patch'))
  972         self.expectCommands(
  973             ExpectShell(workdir='wkdir',
  974                         command=['git', '--version'])
  975             + ExpectShell.log('stdio',
  976                               stdout='git version 1.7.5')
  977             + 0,
  978             Expect('stat', dict(file='wkdir/.buildbot-patched',
  979                                 logEnviron=True))
  980             + 1,
  981             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  982                                'timeout': 1200})
  983             + Expect.update('files', ['.git'])
  984             + 0,
  985             ExpectShell(workdir='wkdir',
  986                         command=['git', 'clean', '-f', '-f', '-d'])
  987             + 0,
  988             ExpectShell(workdir='wkdir',
  989                         command=['git', 'fetch', '-t',
  990                                  'http://github.com/buildbot/buildbot.git',
  991                                  'HEAD'])
  992             + 0,
  993             ExpectShell(workdir='wkdir',
  994                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  995             + 0,
  996             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
  997                                         reader=ExpectRemoteRef(
  998                                             remotetransfer.StringFileReader),
  999                                         workerdest='.buildbot-diff', workdir='wkdir',
 1000                                         mode=None))
 1001             + 0,
 1002             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
 1003                                         reader=ExpectRemoteRef(
 1004                                             remotetransfer.StringFileReader),
 1005                                         workerdest='.buildbot-patched', workdir='wkdir',
 1006                                         mode=None))
 1007             + 0,
 1008             ExpectShell(workdir='wkdir',
 1009                         command=['git', 'update-index', '--refresh'])
 1010             + 0,
 1011             ExpectShell(workdir='wkdir',
 1012                         command=['git', 'apply', '--index', '-p', '1'],
 1013                         initialStdin='patch')
 1014             + 1,
 1015         )
 1016         self.expectOutcome(result=FAILURE)
 1017         self.expectNoProperty('got_revision')
 1018         return self.runStep()
 1019 
 1020     def test_mode_full_clean_branch(self):
 1021         self.setupStep(
 1022             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1023                            mode='full', method='clean', branch='test-branch'))
 1024         self.expectCommands(
 1025             ExpectShell(workdir='wkdir',
 1026                         command=['git', '--version'])
 1027             + ExpectShell.log('stdio',
 1028                               stdout='git version 1.7.5')
 1029             + 0,
 1030             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1031                                 logEnviron=True))
 1032             + 1,
 1033             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1034                                'timeout': 1200})
 1035             + Expect.update('files', ['.git'])
 1036             + 0,
 1037             ExpectShell(workdir='wkdir',
 1038                         command=['git', 'clean', '-f', '-f', '-d'])
 1039             + 0,
 1040             ExpectShell(workdir='wkdir',
 1041                         command=['git', 'fetch', '-t',
 1042                                  'http://github.com/buildbot/buildbot.git',
 1043                                  'test-branch'])
 1044             + 0,
 1045             ExpectShell(workdir='wkdir',
 1046                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1047             + 0,
 1048             ExpectShell(workdir='wkdir',
 1049                         command=['git', 'checkout', '-B', 'test-branch'])
 1050             + 0,
 1051             ExpectShell(workdir='wkdir',
 1052                         command=['git', 'rev-parse', 'HEAD'])
 1053             + ExpectShell.log('stdio',
 1054                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1055             + 0,
 1056         )
 1057         self.expectOutcome(result=SUCCESS)
 1058         self.expectProperty(
 1059             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1060         return self.runStep()
 1061 
 1062     def test_mode_full_clean_non_empty_builddir(self):
 1063         self.setupStep(
 1064             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1065                            mode='full', method='clean', branch='test-branch'))
 1066         self.expectCommands(
 1067             ExpectShell(workdir='wkdir',
 1068                         command=['git', '--version'])
 1069             + ExpectShell.log('stdio',
 1070                               stdout='git version 1.7.5')
 1071             + 0,
 1072             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1073                                 logEnviron=True))
 1074             + 1,
 1075             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1076                                'timeout': 1200})
 1077             + Expect.update('files', ['file1', 'file2'])
 1078             + 0,
 1079             Expect('rmdir', dict(dir='wkdir',
 1080                                  logEnviron=True,
 1081                                  timeout=1200))
 1082             + 0,
 1083             ExpectShell(workdir='wkdir',
 1084                         command=['git', 'clone', '--branch', 'test-branch',
 1085                                  'http://github.com/buildbot/buildbot.git', '.'])
 1086             + 0,
 1087             ExpectShell(workdir='wkdir',
 1088                         command=['git', 'rev-parse', 'HEAD'])
 1089             + ExpectShell.log('stdio',
 1090                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1091             + 0,
 1092         )
 1093         self.expectOutcome(result=SUCCESS)
 1094         self.expectProperty(
 1095             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1096         return self.runStep()
 1097 
 1098     def test_mode_full_clean_parsefail(self):
 1099         self.setupStep(
 1100             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1101                            mode='full', method='clean'))
 1102         self.expectCommands(
 1103             ExpectShell(workdir='wkdir',
 1104                         command=['git', '--version'])
 1105             + ExpectShell.log('stdio',
 1106                               stdout='git version 1.7.5')
 1107             + 0,
 1108             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1109                                 logEnviron=True))
 1110             + 1,
 1111             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1112                                'timeout': 1200})
 1113             + Expect.update('files', ['.git'])
 1114             + 0,
 1115             ExpectShell(workdir='wkdir',
 1116                         command=['git', 'clean', '-f', '-f', '-d'])
 1117             + 0,
 1118             ExpectShell(workdir='wkdir',
 1119                         command=['git', 'fetch', '-t',
 1120                                  'http://github.com/buildbot/buildbot.git',
 1121                                  'HEAD'])
 1122             + 0,
 1123             ExpectShell(workdir='wkdir',
 1124                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1125             + ExpectShell.log('stdio',
 1126                               stderr="fatal: Could not parse object "
 1127                               "'b08076bc71c7813038f2cefedff9c5b678d225a8'.\n")
 1128             + 128,
 1129         )
 1130         self.expectOutcome(result=FAILURE)
 1131         self.expectNoProperty('got_revision')
 1132         return self.runStep()
 1133 
 1134     def test_mode_full_clean_no_existing_repo(self):
 1135         self.setupStep(
 1136             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1137                            mode='full', method='clean'))
 1138         self.expectCommands(
 1139             ExpectShell(workdir='wkdir',
 1140                         command=['git', '--version'])
 1141             + ExpectShell.log('stdio',
 1142                               stdout='git version 1.7.5')
 1143             + 0,
 1144             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1145                                 logEnviron=True))
 1146             + 1,
 1147             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1148                                'timeout': 1200})
 1149             + Expect.update('files', [])
 1150             + 0,
 1151             ExpectShell(workdir='wkdir',
 1152                         command=['git', 'clone',
 1153                                  'http://github.com/buildbot/buildbot.git', '.'])
 1154             + 0,
 1155             ExpectShell(workdir='wkdir',
 1156                         command=['git', 'rev-parse', 'HEAD'])
 1157             + ExpectShell.log('stdio',
 1158                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1159             + 0,
 1160         )
 1161         self.expectOutcome(result=SUCCESS)
 1162         return self.runStep()
 1163 
 1164     def test_mode_full_clean_no_existing_repo_with_reference(self):
 1165         self.setupStep(
 1166             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1167                            mode='full', method='clean', reference='path/to/reference/repo'))
 1168         self.expectCommands(
 1169             ExpectShell(workdir='wkdir',
 1170                         command=['git', '--version'])
 1171             + ExpectShell.log('stdio',
 1172                               stdout='git version 1.7.5')
 1173             + 0,
 1174             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1175                                 logEnviron=True))
 1176             + 1,
 1177             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1178                                'timeout': 1200})
 1179             + Expect.update('files', [])
 1180             + 0,
 1181             ExpectShell(workdir='wkdir',
 1182                         command=['git', 'clone', '--reference', 'path/to/reference/repo',
 1183                                  'http://github.com/buildbot/buildbot.git', '.'])
 1184             + 0,
 1185             ExpectShell(workdir='wkdir',
 1186                         command=['git', 'rev-parse', 'HEAD'])
 1187             + ExpectShell.log('stdio',
 1188                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1189             + 0,
 1190         )
 1191         self.expectOutcome(result=SUCCESS)
 1192         return self.runStep()
 1193 
 1194     def test_mode_full_clean_no_existing_repo_branch(self):
 1195         self.setupStep(
 1196             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1197                            mode='full', method='clean', branch='test-branch'))
 1198         self.expectCommands(
 1199             ExpectShell(workdir='wkdir',
 1200                         command=['git', '--version'])
 1201             + ExpectShell.log('stdio',
 1202                               stdout='git version 1.7.5')
 1203             + 0,
 1204             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1205                                 logEnviron=True))
 1206             + 1,
 1207             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1208                                'timeout': 1200})
 1209             + Expect.update('files', [])
 1210             + 0,
 1211             ExpectShell(workdir='wkdir',
 1212                         command=['git', 'clone',
 1213                                  '--branch', 'test-branch',
 1214                                  'http://github.com/buildbot/buildbot.git', '.'])
 1215             + 0,
 1216             ExpectShell(workdir='wkdir',
 1217                         command=['git', 'rev-parse', 'HEAD'])
 1218             + ExpectShell.log('stdio',
 1219                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1220             + 0,
 1221         )
 1222         self.expectOutcome(result=SUCCESS)
 1223         return self.runStep()
 1224 
 1225     def test_mode_full_clean_no_existing_repo_with_origin(self):
 1226         self.setupStep(
 1227             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1228                            mode='full', method='clean', origin='foo'))
 1229         self.expectCommands(
 1230             ExpectShell(workdir='wkdir',
 1231                         command=['git', '--version'])
 1232             + ExpectShell.log('stdio',
 1233                               stdout='git version 1.7.5')
 1234             + 0,
 1235             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1236                                 logEnviron=True))
 1237             + 1,
 1238             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1239                                'timeout': 1200})
 1240             + Expect.update('files', [])
 1241             + 0,
 1242             ExpectShell(workdir='wkdir',
 1243                         command=['git', 'clone', '--origin', 'foo',
 1244                                  'http://github.com/buildbot/buildbot.git', '.'])
 1245             + 0,
 1246             ExpectShell(workdir='wkdir',
 1247                         command=['git', 'rev-parse', 'HEAD'])
 1248             + ExpectShell.log('stdio',
 1249                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1250             + 0,
 1251         )
 1252         self.expectOutcome(result=SUCCESS)
 1253         return self.runStep()
 1254 
 1255     def test_mode_full_clean_submodule(self):
 1256         self.setupStep(
 1257             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1258                            mode='full', method='clean', submodules=True))
 1259         self.expectCommands(
 1260             ExpectShell(workdir='wkdir',
 1261                         command=['git', '--version'])
 1262             + ExpectShell.log('stdio',
 1263                               stdout='git version 1.7.5')
 1264             + 0,
 1265             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1266                                 logEnviron=True))
 1267             + 1,
 1268             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1269                                'timeout': 1200})
 1270             + Expect.update('files', ['.git'])
 1271             + 0,
 1272             ExpectShell(workdir='wkdir',
 1273                         command=['git', 'clean', '-f', '-f', '-d'])
 1274             + 0,
 1275             ExpectShell(workdir='wkdir',
 1276                         command=['git', 'fetch', '-t',
 1277                                  'http://github.com/buildbot/buildbot.git',
 1278                                  'HEAD'])
 1279             + 0,
 1280             ExpectShell(workdir='wkdir',
 1281                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1282             + 0,
 1283             ExpectShell(workdir='wkdir',
 1284                         command=['git', 'submodule', 'sync'])
 1285             + 0,
 1286             ExpectShell(workdir='wkdir',
 1287                         command=['git', 'submodule', 'update', '--init', '--recursive'])
 1288             + 0,
 1289             ExpectShell(workdir='wkdir',
 1290                         command=['git', 'submodule', 'foreach', '--recursive', 'git', 'clean',
 1291                                  '-f', '-f', '-d'])
 1292             + 0,
 1293             ExpectShell(workdir='wkdir',
 1294                         command=['git', 'clean', '-f', '-f', '-d'])
 1295             + 0,
 1296             ExpectShell(workdir='wkdir',
 1297                         command=['git', 'rev-parse', 'HEAD'])
 1298             + ExpectShell.log('stdio',
 1299                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1300             + 0,
 1301         )
 1302         self.expectOutcome(result=SUCCESS)
 1303         self.expectProperty(
 1304             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1305         return self.runStep()
 1306 
 1307     def test_mode_full_clobber(self):
 1308         self.setupStep(
 1309             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1310                            mode='full', method='clobber', progress=True))
 1311 
 1312         self.expectCommands(
 1313             ExpectShell(workdir='wkdir',
 1314                         command=['git', '--version'])
 1315             + ExpectShell.log('stdio',
 1316                               stdout='git version 1.7.5')
 1317             + 0,
 1318             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1319                                 logEnviron=True))
 1320             + 1,
 1321             Expect('rmdir', dict(dir='wkdir',
 1322                                  logEnviron=True,
 1323                                  timeout=1200))
 1324             + 0,
 1325             ExpectShell(workdir='wkdir',
 1326                         command=['git', 'clone',
 1327                                  'http://github.com/buildbot/buildbot.git',
 1328                                  '.', '--progress'])
 1329             + 0,
 1330             ExpectShell(workdir='wkdir',
 1331                         command=['git', 'rev-parse', 'HEAD'])
 1332             + ExpectShell.log('stdio',
 1333                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1334             + 0,
 1335         )
 1336         self.expectOutcome(result=SUCCESS)
 1337         self.expectProperty(
 1338             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1339         return self.runStep()
 1340 
 1341     def test_mode_full_clone_fails(self):
 1342         self.setupStep(
 1343             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1344                            mode='full', method='clobber', progress=True))
 1345 
 1346         self.expectCommands(
 1347             ExpectShell(workdir='wkdir',
 1348                         command=['git', '--version'])
 1349             + ExpectShell.log('stdio',
 1350                               stdout='git version 1.7.5')
 1351             + 0,
 1352             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1353                                 logEnviron=True))
 1354             + 1,
 1355             Expect('rmdir', dict(dir='wkdir',
 1356                                  logEnviron=True,
 1357                                  timeout=1200))
 1358             + 0,
 1359             ExpectShell(workdir='wkdir',
 1360                         command=['git', 'clone',
 1361                                  'http://github.com/buildbot/buildbot.git',
 1362                                  '.', '--progress'])
 1363             + 1,  # clone fails
 1364         )
 1365         self.expectOutcome(result=FAILURE, state_string="update (failure)")
 1366         self.expectNoProperty('got_revision')
 1367         return self.runStep()
 1368 
 1369     def test_mode_full_clobber_branch(self):
 1370         self.setupStep(
 1371             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1372                            mode='full', method='clobber', progress=True, branch='test-branch'))
 1373 
 1374         self.expectCommands(
 1375             ExpectShell(workdir='wkdir',
 1376                         command=['git', '--version'])
 1377             + ExpectShell.log('stdio',
 1378                               stdout='git version 1.7.5')
 1379             + 0,
 1380             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1381                                 logEnviron=True))
 1382             + 1,
 1383             Expect('rmdir', dict(dir='wkdir',
 1384                                  logEnviron=True,
 1385                                  timeout=1200))
 1386             + 0,
 1387             ExpectShell(workdir='wkdir',
 1388                         command=['git', 'clone',
 1389                                  '--branch', 'test-branch',
 1390                                  'http://github.com/buildbot/buildbot.git',
 1391                                  '.', '--progress'])
 1392             + 0,
 1393             ExpectShell(workdir='wkdir',
 1394                         command=['git', 'rev-parse', 'HEAD'])
 1395             + ExpectShell.log('stdio',
 1396                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1397             + 0,
 1398         )
 1399         self.expectOutcome(result=SUCCESS)
 1400         self.expectProperty(
 1401             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1402         return self.runStep()
 1403 
 1404     def test_mode_full_clobber_no_branch_support(self):
 1405         self.setupStep(
 1406             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1407                            mode='full', method='clobber', progress=True, branch='test-branch'))
 1408 
 1409         self.expectCommands(
 1410             ExpectShell(workdir='wkdir',
 1411                         command=['git', '--version'])
 1412             + ExpectShell.log('stdio',
 1413                               stdout='git version 1.5.5')
 1414             + 0,
 1415             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1416                                 logEnviron=True))
 1417             + 1,
 1418             Expect('rmdir', dict(dir='wkdir',
 1419                                  logEnviron=True,
 1420                                  timeout=1200))
 1421             + 0,
 1422             ExpectShell(workdir='wkdir',
 1423                         command=['git', 'clone',
 1424                                  'http://github.com/buildbot/buildbot.git',
 1425                                  '.', '--progress'])
 1426             + 0,
 1427             ExpectShell(workdir='wkdir',
 1428                         command=['git', 'rev-parse', 'HEAD'])
 1429             + ExpectShell.log('stdio',
 1430                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1431             + 0,
 1432         )
 1433         self.expectOutcome(result=SUCCESS)
 1434         self.expectProperty(
 1435             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1436         return self.runStep()
 1437 
 1438     def test_mode_incremental_oldworker(self):
 1439         self.setupStep(
 1440             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1441                            mode='incremental'))
 1442         self.step.build.getWorkerCommandVersion = lambda cmd, oldversion: "2.15"
 1443         self.expectCommands(
 1444             ExpectShell(workdir='wkdir',
 1445                         command=['git', '--version'])
 1446             + ExpectShell.log('stdio',
 1447                               stdout='git version 1.7.5')
 1448             + 0,
 1449             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1450                                 logEnviron=True))
 1451             + 1,
 1452             Expect('stat', dict(file='wkdir/.git',
 1453                                 logEnviron=True))
 1454             + 0,
 1455             ExpectShell(workdir='wkdir',
 1456                         command=['git', 'fetch', '-t',
 1457                                  'http://github.com/buildbot/buildbot.git',
 1458                                  'HEAD'])
 1459             + 0,
 1460             ExpectShell(workdir='wkdir',
 1461                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1462             + 0,
 1463             ExpectShell(workdir='wkdir',
 1464                         command=['git', 'rev-parse', 'HEAD'])
 1465             + ExpectShell.log('stdio',
 1466                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1467             + 0,
 1468 
 1469         )
 1470         self.expectOutcome(result=SUCCESS)
 1471         self.expectProperty(
 1472             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1473         return self.runStep()
 1474 
 1475     def test_mode_incremental(self):
 1476         self.setupStep(
 1477             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1478                            mode='incremental'))
 1479         self.expectCommands(
 1480             ExpectShell(workdir='wkdir',
 1481                         command=['git', '--version'])
 1482             + ExpectShell.log('stdio',
 1483                               stdout='git version 1.7.5')
 1484             + 0,
 1485             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1486                                 logEnviron=True))
 1487             + 1,
 1488             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1489                                'timeout': 1200})
 1490             + Expect.update('files', ['.git'])
 1491             + 0,
 1492             ExpectShell(workdir='wkdir',
 1493                         command=['git', 'fetch', '-t',
 1494                                  'http://github.com/buildbot/buildbot.git',
 1495                                  'HEAD'])
 1496             + 0,
 1497             ExpectShell(workdir='wkdir',
 1498                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1499             + 0,
 1500             ExpectShell(workdir='wkdir',
 1501                         command=['git', 'rev-parse', 'HEAD'])
 1502             + ExpectShell.log('stdio',
 1503                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1504             + 0,
 1505 
 1506         )
 1507         self.expectOutcome(result=SUCCESS)
 1508         self.expectProperty(
 1509             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1510         return self.runStep()
 1511 
 1512     def test_version_format(self):
 1513         self.setupStep(
 1514             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1515                            mode='incremental'))
 1516         self.expectCommands(
 1517             ExpectShell(workdir='wkdir',
 1518                         command=['git', '--version'])
 1519             + ExpectShell.log('stdio',
 1520                               stdout='git version 1.7.5.1')
 1521             + 0,
 1522             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1523                                 logEnviron=True))
 1524             + 1,
 1525             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1526                                'timeout': 1200})
 1527             + Expect.update('files', ['.git'])
 1528             + 0,
 1529             ExpectShell(workdir='wkdir',
 1530                         command=['git', 'fetch', '-t',
 1531                                  'http://github.com/buildbot/buildbot.git',
 1532                                  'HEAD'])
 1533             + 0,
 1534             ExpectShell(workdir='wkdir',
 1535                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1536             + 0,
 1537             ExpectShell(workdir='wkdir',
 1538                         command=['git', 'rev-parse', 'HEAD'])
 1539             + ExpectShell.log('stdio',
 1540                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1541             + 0,
 1542 
 1543         )
 1544         self.expectOutcome(result=SUCCESS)
 1545         self.expectProperty(
 1546             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1547         return self.runStep()
 1548 
 1549     def test_mode_incremental_retry(self):
 1550         self.setupStep(
 1551             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1552                            mode='incremental', retry=(0, 1)))
 1553         self.expectCommands(
 1554             ExpectShell(workdir='wkdir',
 1555                         command=['git', '--version'])
 1556             + ExpectShell.log('stdio',
 1557                               stdout='git version 1.7.5')
 1558             + 0,
 1559             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1560                                 logEnviron=True))
 1561             + 1,
 1562             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1563                                'timeout': 1200})
 1564             + Expect.update('files', [])
 1565             + 0,
 1566             ExpectShell(workdir='wkdir',
 1567                         command=['git', 'clone',
 1568                                  'http://github.com/buildbot/buildbot.git',
 1569                                  '.'])
 1570             + 1,
 1571             Expect('rmdir', dict(dir='wkdir',
 1572                                  logEnviron=True,
 1573                                  timeout=1200))
 1574             + 0,
 1575             ExpectShell(workdir='wkdir',
 1576                         command=['git', 'clone',
 1577                                  'http://github.com/buildbot/buildbot.git',
 1578                                  '.'])
 1579             + 0,
 1580             ExpectShell(workdir='wkdir',
 1581                         command=['git', 'rev-parse', 'HEAD'])
 1582             + ExpectShell.log('stdio',
 1583                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1584             + 0,
 1585         )
 1586         self.expectOutcome(result=SUCCESS)
 1587         self.expectProperty(
 1588             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1589         return self.runStep()
 1590 
 1591     def test_mode_incremental_branch(self):
 1592         self.setupStep(
 1593             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1594                            mode='incremental', branch='test-branch'))
 1595         self.expectCommands(
 1596             ExpectShell(workdir='wkdir',
 1597                         command=['git', '--version'])
 1598             + ExpectShell.log('stdio',
 1599                               stdout='git version 1.7.5')
 1600             + 0,
 1601             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1602                                 logEnviron=True))
 1603             + 1,
 1604             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1605                                'timeout': 1200})
 1606             + Expect.update('files', ['.git'])
 1607             + 0,
 1608             ExpectShell(workdir='wkdir',
 1609                         command=['git', 'fetch', '-t',
 1610                                  'http://github.com/buildbot/buildbot.git',
 1611                                  'test-branch'])
 1612             + 0,
 1613             ExpectShell(workdir='wkdir',
 1614                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1615             + 0,
 1616             ExpectShell(workdir='wkdir',
 1617                         command=['git', 'checkout', '-B', 'test-branch'])
 1618             + 0,
 1619             ExpectShell(workdir='wkdir',
 1620                         command=['git', 'rev-parse', 'HEAD'])
 1621             + ExpectShell.log('stdio',
 1622                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1623             + 0,
 1624 
 1625         )
 1626         self.expectOutcome(result=SUCCESS)
 1627         self.expectProperty(
 1628             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1629         return self.runStep()
 1630 
 1631     def test_mode_incremental_branch_ssh_key_2_10(self):
 1632         self.setupStep(
 1633             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1634                            mode='incremental', branch='test-branch',
 1635                            sshPrivateKey='ssh-key'))
 1636 
 1637         ssh_workdir = '/wrk/.wkdir.buildbot'
 1638         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 1639         ssh_command_config = \
 1640             'core.sshCommand=ssh -i "{0}"'.format(ssh_key_path)
 1641 
 1642         self.expectCommands(
 1643             ExpectShell(workdir='wkdir',
 1644                         command=['git', '--version'])
 1645             + ExpectShell.log('stdio',
 1646                               stdout='git version 2.10.0')
 1647             + 0,
 1648             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1649                                 logEnviron=True))
 1650             + 1,
 1651             Expect('mkdir', dict(dir=ssh_workdir,
 1652                                  logEnviron=True))
 1653             + 0,
 1654             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
 1655                                         reader=ExpectRemoteRef(
 1656                                             remotetransfer.StringFileReader),
 1657                                         workerdest=ssh_key_path,
 1658                                         workdir='wkdir',
 1659                                         mode=0o400))
 1660             + 0,
 1661             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1662                                'timeout': 1200})
 1663             + Expect.update('files', ['.git'])
 1664             + 0,
 1665             ExpectShell(workdir='wkdir',
 1666                         command=['git', '-c', ssh_command_config,
 1667                                  'fetch', '-t',
 1668                                  'http://github.com/buildbot/buildbot.git',
 1669                                  'test-branch'])
 1670             + 0,
 1671             ExpectShell(workdir='wkdir',
 1672                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1673             + 0,
 1674             ExpectShell(workdir='wkdir',
 1675                         command=['git', 'checkout', '-B', 'test-branch'])
 1676             + 0,
 1677             ExpectShell(workdir='wkdir',
 1678                         command=['git', 'rev-parse', 'HEAD'])
 1679             + ExpectShell.log('stdio',
 1680                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1681             + 0,
 1682             Expect('rmdir', dict(dir=ssh_workdir,
 1683                                  logEnviron=True))
 1684             + 0,
 1685         )
 1686         self.expectOutcome(result=SUCCESS)
 1687         self.expectProperty(
 1688             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1689         return self.runStep()
 1690 
 1691     def test_mode_full_fresh(self):
 1692         self.setupStep(
 1693             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1694                            mode='full', method='fresh'))
 1695         self.expectCommands(
 1696             ExpectShell(workdir='wkdir',
 1697                         command=['git', '--version'])
 1698             + ExpectShell.log('stdio',
 1699                               stdout='git version 1.7.5')
 1700             + 0,
 1701             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1702                                 logEnviron=True))
 1703             + 1,
 1704             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1705                                'timeout': 1200})
 1706             + Expect.update('files', ['.git'])
 1707             + 0,
 1708             ExpectShell(workdir='wkdir',
 1709                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1710             + 0,
 1711             ExpectShell(workdir='wkdir',
 1712                         command=['git', 'fetch', '-t',
 1713                                  'http://github.com/buildbot/buildbot.git',
 1714                                  'HEAD'])
 1715             + 0,
 1716             ExpectShell(workdir='wkdir',
 1717                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1718             + 0,
 1719             ExpectShell(workdir='wkdir',
 1720                         command=['git', 'rev-parse', 'HEAD'])
 1721             + ExpectShell.log('stdio',
 1722                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1723             + 0,
 1724         )
 1725         self.expectOutcome(result=SUCCESS)
 1726         self.expectProperty(
 1727             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1728         return self.runStep()
 1729 
 1730     def test_mode_full_fresh_clean_fails(self):
 1731         self.setupStep(
 1732             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1733                            mode='full', method='fresh'))
 1734         self.expectCommands(
 1735             ExpectShell(workdir='wkdir',
 1736                         command=['git', '--version'])
 1737             + ExpectShell.log('stdio',
 1738                               stdout='git version 1.7.5')
 1739             + 0,
 1740             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1741                                 logEnviron=True))
 1742             + 1,
 1743             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1744                                'timeout': 1200})
 1745             + Expect.update('files', ['.git'])
 1746             + 0,
 1747             ExpectShell(workdir='wkdir',
 1748                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1749             + 1,  # clean fails -> clobber
 1750             Expect('rmdir', dict(dir='wkdir',
 1751                                  logEnviron=True,
 1752                                  timeout=1200))
 1753             + 0,
 1754             ExpectShell(workdir='wkdir',
 1755                         command=['git', 'clone',
 1756                                  'http://github.com/buildbot/buildbot.git',
 1757                                  '.'])
 1758             + 0,
 1759             ExpectShell(workdir='wkdir',
 1760                         command=['git', 'rev-parse', 'HEAD'])
 1761             + ExpectShell.log('stdio',
 1762                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1763             + 0,
 1764         )
 1765         self.expectOutcome(result=SUCCESS)
 1766         self.expectProperty(
 1767             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1768         return self.runStep()
 1769 
 1770     def test_mode_incremental_given_revision(self):
 1771         self.setupStep(
 1772             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1773                            mode='incremental'), dict(
 1774                 revision='abcdef01',
 1775             ))
 1776         self.expectCommands(
 1777             ExpectShell(workdir='wkdir',
 1778                         command=['git', '--version'])
 1779             + ExpectShell.log('stdio',
 1780                               stdout='git version 1.7.5')
 1781             + 0,
 1782             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1783                                 logEnviron=True))
 1784             + 1,
 1785             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1786                                'timeout': 1200})
 1787             + Expect.update('files', ['.git'])
 1788             + 0,
 1789             ExpectShell(workdir='wkdir',
 1790                         command=['git', 'cat-file', '-e', 'abcdef01'])
 1791             + 0,
 1792             ExpectShell(workdir='wkdir',
 1793                         command=['git', 'reset', '--hard', 'abcdef01', '--'])
 1794             + 0,
 1795             ExpectShell(workdir='wkdir',
 1796                         command=['git', 'rev-parse', 'HEAD'])
 1797             + ExpectShell.log('stdio',
 1798                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1799             + 0,
 1800         )
 1801         self.expectOutcome(result=SUCCESS)
 1802         self.expectProperty(
 1803             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1804         return self.runStep()
 1805 
 1806     def test_mode_incremental_given_revision_not_exists(self):
 1807         self.setupStep(
 1808             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1809                            mode='incremental'), dict(
 1810                 revision='abcdef01',
 1811             ))
 1812         self.expectCommands(
 1813             ExpectShell(workdir='wkdir',
 1814                         command=['git', '--version'])
 1815             + ExpectShell.log('stdio',
 1816                               stdout='git version 1.7.5')
 1817             + 0,
 1818             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1819                                 logEnviron=True))
 1820             + 1,
 1821             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1822                                'timeout': 1200})
 1823             + Expect.update('files', ['.git'])
 1824             + 0,
 1825             ExpectShell(workdir='wkdir',
 1826                         command=['git', 'cat-file', '-e', 'abcdef01'])
 1827             + 1,
 1828             ExpectShell(workdir='wkdir',
 1829                         command=['git', 'fetch', '-t',
 1830                                  'http://github.com/buildbot/buildbot.git',
 1831                                  'HEAD'])
 1832             + 0,
 1833             ExpectShell(workdir='wkdir',
 1834                         command=['git', 'reset', '--hard', 'abcdef01', '--'])
 1835             + 0,
 1836             ExpectShell(workdir='wkdir',
 1837                         command=['git', 'rev-parse', 'HEAD'])
 1838             + ExpectShell.log('stdio',
 1839                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1840             + 0,
 1841         )
 1842         self.expectOutcome(result=SUCCESS)
 1843         self.expectProperty(
 1844             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1845         return self.runStep()
 1846 
 1847     def test_mode_full_fresh_submodule(self):
 1848         self.setupStep(
 1849             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1850                            mode='full', method='fresh', submodules=True))
 1851         self.expectCommands(
 1852             ExpectShell(workdir='wkdir',
 1853                         command=['git', '--version'])
 1854             + ExpectShell.log('stdio',
 1855                               stdout='git version 1.7.5')
 1856             + 0,
 1857             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1858                                 logEnviron=True))
 1859             + 1,
 1860             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1861                                'timeout': 1200})
 1862             + Expect.update('files', ['.git'])
 1863             + 0,
 1864             ExpectShell(workdir='wkdir',
 1865                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1866             + 0,
 1867             ExpectShell(workdir='wkdir',
 1868                         command=['git', 'fetch', '-t',
 1869                                  'http://github.com/buildbot/buildbot.git',
 1870                                  'HEAD'])
 1871             + 0,
 1872             ExpectShell(workdir='wkdir',
 1873                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1874             + 0,
 1875             ExpectShell(workdir='wkdir',
 1876                         command=['git', 'submodule', 'sync'])
 1877             + 0,
 1878             ExpectShell(workdir='wkdir',
 1879                         command=['git', 'submodule', 'update', '--init', '--recursive'])
 1880             + 0,
 1881             ExpectShell(workdir='wkdir',
 1882                         command=['git', 'submodule', 'foreach', '--recursive', 'git', 'clean',
 1883                                  '-f', '-f', '-d', '-x'])
 1884             + 0,
 1885             ExpectShell(workdir='wkdir',
 1886                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1887             + 0,
 1888             ExpectShell(workdir='wkdir',
 1889                         command=['git', 'rev-parse', 'HEAD'])
 1890             + ExpectShell.log('stdio',
 1891                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1892             + 0,
 1893         )
 1894         self.expectOutcome(result=SUCCESS, state_string="update")
 1895         self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1896         return self.runStep()
 1897 
 1898     def test_mode_full_fresh_submodule_git_newer_1_7_6(self):
 1899         self.setupStep(
 1900             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1901                            mode='full', method='fresh', submodules=True))
 1902         self.expectCommands(
 1903             ExpectShell(workdir='wkdir',
 1904                         command=['git', '--version'])
 1905             + ExpectShell.log('stdio',
 1906                               stdout='git version 1.7.6')
 1907             + 0,
 1908             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1909                                 logEnviron=True))
 1910             + 1,
 1911             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1912                                'timeout': 1200})
 1913             + Expect.update('files', ['.git'])
 1914             + 0,
 1915             ExpectShell(workdir='wkdir',
 1916                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1917             + 0,
 1918             ExpectShell(workdir='wkdir',
 1919                         command=['git', 'fetch', '-t',
 1920                                  'http://github.com/buildbot/buildbot.git',
 1921                                  'HEAD'])
 1922             + 0,
 1923             ExpectShell(workdir='wkdir',
 1924                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1925             + 0,
 1926             ExpectShell(workdir='wkdir',
 1927                         command=['git', 'submodule', 'sync'])
 1928             + 0,
 1929             ExpectShell(workdir='wkdir',
 1930                         command=['git', 'submodule', 'update', '--init', '--recursive', '--force'])
 1931             + 0,
 1932             ExpectShell(workdir='wkdir',
 1933                         command=['git', 'submodule', 'foreach', '--recursive', 'git', 'clean',
 1934                                  '-f', '-f', '-d', '-x'])
 1935             + 0,
 1936             ExpectShell(workdir='wkdir',
 1937                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1938             + 0,
 1939             ExpectShell(workdir='wkdir',
 1940                         command=['git', 'rev-parse', 'HEAD'])
 1941             + ExpectShell.log('stdio',
 1942                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1943             + 0,
 1944         )
 1945         self.expectOutcome(result=SUCCESS)
 1946         self.expectProperty(
 1947             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 1948         return self.runStep()
 1949 
 1950     def test_mode_full_fresh_submodule_v1_7_8(self):
 1951         """This tests the same as test_mode_full_fresh_submodule, but the
 1952         "submodule update" command should be different for Git v1.7.8+."""
 1953         self.setupStep(
 1954             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 1955                            mode='full', method='fresh', submodules=True))
 1956         self.expectCommands(
 1957             ExpectShell(workdir='wkdir',
 1958                         command=['git', '--version'])
 1959             + ExpectShell.log('stdio',
 1960                               stdout='git version 1.7.8')
 1961             + 0,
 1962             Expect('stat', dict(file='wkdir/.buildbot-patched',
 1963                                 logEnviron=True))
 1964             + 1,
 1965             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 1966                                'timeout': 1200})
 1967             + Expect.update('files', ['.git'])
 1968             + 0,
 1969             ExpectShell(workdir='wkdir',
 1970                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1971             + 0,
 1972             ExpectShell(workdir='wkdir',
 1973                         command=['git', 'fetch', '-t',
 1974                                  'http://github.com/buildbot/buildbot.git',
 1975                                  'HEAD'])
 1976             + 0,
 1977             ExpectShell(workdir='wkdir',
 1978                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 1979             + 0,
 1980             ExpectShell(workdir='wkdir',
 1981                         command=['git', 'submodule', 'sync'])
 1982             + 0,
 1983             ExpectShell(workdir='wkdir',
 1984                         command=['git', 'submodule', 'update', '--init', '--recursive',
 1985                                  '--force', '--checkout'])
 1986             + 0,
 1987             ExpectShell(workdir='wkdir',
 1988                         command=['git', 'submodule', 'foreach', '--recursive', 'git', 'clean',
 1989                                  '-f', '-f', '-d', '-x'])
 1990             + 0,
 1991             ExpectShell(workdir='wkdir',
 1992                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 1993             + 0,
 1994             ExpectShell(workdir='wkdir',
 1995                         command=['git', 'rev-parse', 'HEAD'])
 1996             + ExpectShell.log('stdio',
 1997                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 1998             + 0,
 1999         )
 2000         self.expectOutcome(result=SUCCESS)
 2001         self.expectProperty(
 2002             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2003         return self.runStep()
 2004 
 2005     def test_mode_full_clobber_shallow(self):
 2006         self.setupStep(
 2007             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2008                            mode='full', method='clobber', shallow=True))
 2009 
 2010         self.expectCommands(
 2011             ExpectShell(workdir='wkdir',
 2012                         command=['git', '--version'])
 2013             + ExpectShell.log('stdio',
 2014                               stdout='git version 1.7.5')
 2015             + 0,
 2016             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2017                                 logEnviron=True))
 2018             + 1,
 2019             Expect('rmdir', dict(dir='wkdir',
 2020                                  logEnviron=True,
 2021                                  timeout=1200))
 2022             + 0,
 2023             ExpectShell(workdir='wkdir',
 2024                         command=['git', 'clone', '--depth', '1',
 2025                                  'http://github.com/buildbot/buildbot.git',
 2026                                  '.'])
 2027             + 0,
 2028             ExpectShell(workdir='wkdir',
 2029                         command=['git', 'rev-parse', 'HEAD'])
 2030             + ExpectShell.log('stdio',
 2031                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2032             + 0,
 2033         )
 2034         self.expectOutcome(result=SUCCESS)
 2035         self.expectProperty(
 2036             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2037         return self.runStep()
 2038 
 2039     def test_mode_full_clobber_shallow_depth(self):
 2040         self.setupStep(
 2041             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2042                            mode='full', method='clobber', shallow="100"))
 2043 
 2044         self.expectCommands(
 2045             ExpectShell(workdir='wkdir',
 2046                         command=['git', '--version'])
 2047             + ExpectShell.log('stdio',
 2048                               stdout='git version 1.7.5')
 2049             + 0,
 2050             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2051                                 logEnviron=True))
 2052             + 1,
 2053             Expect('rmdir', dict(dir='wkdir',
 2054                                  logEnviron=True,
 2055                                  timeout=1200))
 2056             + 0,
 2057             ExpectShell(workdir='wkdir',
 2058                         command=['git', 'clone', '--depth', '100',
 2059                                  'http://github.com/buildbot/buildbot.git',
 2060                                  '.'])
 2061             + 0,
 2062             ExpectShell(workdir='wkdir',
 2063                         command=['git', 'rev-parse', 'HEAD'])
 2064             + ExpectShell.log('stdio',
 2065                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2066             + 0,
 2067         )
 2068         self.expectOutcome(result=SUCCESS)
 2069         self.expectProperty(
 2070             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2071         return self.runStep()
 2072 
 2073     def test_mode_full_clobber_no_shallow(self):
 2074         self.setupStep(
 2075             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2076                            mode='full', method='clobber'))
 2077 
 2078         self.expectCommands(
 2079             ExpectShell(workdir='wkdir',
 2080                         command=['git', '--version'])
 2081             + ExpectShell.log('stdio',
 2082                               stdout='git version 1.7.5')
 2083             + 0,
 2084             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2085                                 logEnviron=True))
 2086             + 1,
 2087             Expect('rmdir', dict(dir='wkdir',
 2088                                  logEnviron=True,
 2089                                  timeout=1200))
 2090             + 0,
 2091             ExpectShell(workdir='wkdir',
 2092                         command=['git', 'clone',
 2093                                  'http://github.com/buildbot/buildbot.git',
 2094                                  '.'])
 2095             + 0,
 2096             ExpectShell(workdir='wkdir',
 2097                         command=['git', 'rev-parse', 'HEAD'])
 2098             + ExpectShell.log('stdio',
 2099                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2100             + 0,
 2101         )
 2102         self.expectOutcome(result=SUCCESS)
 2103         self.expectProperty(
 2104             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2105         return self.runStep()
 2106 
 2107     def test_mode_incremental_retryFetch(self):
 2108         self.setupStep(
 2109             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2110                            mode='incremental', retryFetch=True))
 2111 
 2112         self.expectCommands(
 2113             ExpectShell(workdir='wkdir',
 2114                         command=['git', '--version'])
 2115             + ExpectShell.log('stdio',
 2116                               stdout='git version 1.7.5')
 2117             + 0,
 2118             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2119                                 logEnviron=True))
 2120             + 1,
 2121             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2122                                'timeout': 1200})
 2123             + Expect.update('files', ['.git'])
 2124             + 0,
 2125             ExpectShell(workdir='wkdir',
 2126                         command=['git', 'fetch', '-t',
 2127                                  'http://github.com/buildbot/buildbot.git',
 2128                                  'HEAD'])
 2129             + 0,
 2130             ExpectShell(workdir='wkdir',
 2131                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2132             + 1,
 2133             ExpectShell(workdir='wkdir',
 2134                         command=['git', 'fetch', '-t',
 2135                                  'http://github.com/buildbot/buildbot.git',
 2136                                  'HEAD'])
 2137             + 0,
 2138             ExpectShell(workdir='wkdir',
 2139                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2140             + 0,
 2141             ExpectShell(workdir='wkdir',
 2142                         command=['git', 'rev-parse', 'HEAD'])
 2143             + ExpectShell.log('stdio',
 2144                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2145             + 0,
 2146         )
 2147         self.expectOutcome(result=SUCCESS)
 2148         self.expectProperty(
 2149             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2150         return self.runStep()
 2151 
 2152     def test_mode_incremental_retryFetch_branch(self):
 2153         self.setupStep(
 2154             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2155                            mode='incremental', retryFetch=True, branch='test-branch'))
 2156 
 2157         self.expectCommands(
 2158             ExpectShell(workdir='wkdir',
 2159                         command=['git', '--version'])
 2160             + ExpectShell.log('stdio',
 2161                               stdout='git version 1.7.5')
 2162             + 0,
 2163             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2164                                 logEnviron=True))
 2165             + 1,
 2166             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2167                                'timeout': 1200})
 2168             + Expect.update('files', ['.git'])
 2169             + 0,
 2170             ExpectShell(workdir='wkdir',
 2171                         command=['git', 'fetch', '-t',
 2172                                  'http://github.com/buildbot/buildbot.git',
 2173                                  'test-branch'])
 2174             + 0,
 2175             ExpectShell(workdir='wkdir',
 2176                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2177             + 1,
 2178             ExpectShell(workdir='wkdir',
 2179                         command=['git', 'fetch', '-t',
 2180                                  'http://github.com/buildbot/buildbot.git',
 2181                                  'test-branch'])
 2182             + 0,
 2183             ExpectShell(workdir='wkdir',
 2184                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2185             + 0,
 2186             ExpectShell(workdir='wkdir',
 2187                         command=['git', 'checkout', '-B', 'test-branch'])
 2188             + 0,
 2189             ExpectShell(workdir='wkdir',
 2190                         command=['git', 'rev-parse', 'HEAD'])
 2191             + ExpectShell.log('stdio',
 2192                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2193             + 0,
 2194         )
 2195         self.expectOutcome(result=SUCCESS)
 2196         self.expectProperty(
 2197             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2198         return self.runStep()
 2199 
 2200     def test_mode_incremental_clobberOnFailure(self):
 2201         self.setupStep(
 2202             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2203                            mode='incremental', clobberOnFailure=True))
 2204 
 2205         self.expectCommands(
 2206             ExpectShell(workdir='wkdir',
 2207                         command=['git', '--version'])
 2208             + ExpectShell.log('stdio',
 2209                               stdout='git version 1.7.5')
 2210             + 0,
 2211             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2212                                 logEnviron=True))
 2213             + 1,
 2214             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2215                                'timeout': 1200})
 2216             + Expect.update('files', ['.git'])
 2217             + 0,
 2218             ExpectShell(workdir='wkdir',
 2219                         command=['git', 'fetch', '-t',
 2220                                  'http://github.com/buildbot/buildbot.git',
 2221                                  'HEAD'])
 2222             + 0,
 2223             ExpectShell(workdir='wkdir',
 2224                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2225             + 1,
 2226             Expect('rmdir', dict(dir='wkdir',
 2227                                  logEnviron=True,
 2228                                  timeout=1200))
 2229             + 0,
 2230             ExpectShell(workdir='wkdir',
 2231                         command=['git', 'clone',
 2232                                  'http://github.com/buildbot/buildbot.git',
 2233                                  '.'])
 2234             + 0,
 2235             ExpectShell(workdir='wkdir',
 2236                         command=['git', 'rev-parse', 'HEAD'])
 2237             + ExpectShell.log('stdio',
 2238                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2239             + 0,
 2240         )
 2241         self.expectOutcome(result=SUCCESS)
 2242         self.expectProperty(
 2243             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2244         return self.runStep()
 2245 
 2246     def test_mode_incremental_clobberOnFailure_branch(self):
 2247         self.setupStep(
 2248             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2249                            mode='incremental', clobberOnFailure=True, branch='test-branch'))
 2250 
 2251         self.expectCommands(
 2252             ExpectShell(workdir='wkdir',
 2253                         command=['git', '--version'])
 2254             + ExpectShell.log('stdio',
 2255                               stdout='git version 1.7.5')
 2256             + 0,
 2257             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2258                                 logEnviron=True))
 2259             + 1,
 2260             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2261                                'timeout': 1200})
 2262             + Expect.update('files', ['.git'])
 2263             + 0,
 2264             ExpectShell(workdir='wkdir',
 2265                         command=['git', 'fetch', '-t',
 2266                                  'http://github.com/buildbot/buildbot.git',
 2267                                  'test-branch'])
 2268             + 0,
 2269             ExpectShell(workdir='wkdir',
 2270                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2271             + 1,
 2272             Expect('rmdir', dict(dir='wkdir',
 2273                                  logEnviron=True,
 2274                                  timeout=1200))
 2275             + 0,
 2276             ExpectShell(workdir='wkdir',
 2277                         command=['git', 'clone',
 2278                                  '--branch', 'test-branch',
 2279                                  'http://github.com/buildbot/buildbot.git',
 2280                                  '.'])
 2281             + 0,
 2282             ExpectShell(workdir='wkdir',
 2283                         command=['git', 'rev-parse', 'HEAD'])
 2284             + ExpectShell.log('stdio',
 2285                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2286             + 0,
 2287         )
 2288         self.expectOutcome(result=SUCCESS)
 2289         self.expectProperty(
 2290             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2291         return self.runStep()
 2292 
 2293     def test_mode_full_copy(self):
 2294         self.setupStep(
 2295             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2296                            mode='full', method='copy'))
 2297 
 2298         self.expectCommands(
 2299             ExpectShell(workdir='wkdir',
 2300                         command=['git', '--version'])
 2301             + ExpectShell.log('stdio',
 2302                               stdout='git version 1.7.5')
 2303             + 0,
 2304             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2305                                 logEnviron=True))
 2306             + 1,
 2307             Expect('rmdir', dict(dir='wkdir',
 2308                                  logEnviron=True,
 2309                                  timeout=1200)),
 2310             Expect('listdir', {'dir': 'source', 'logEnviron': True,
 2311                                'timeout': 1200})
 2312             + Expect.update('files', ['.git'])
 2313             + 0,
 2314             ExpectShell(workdir='source',
 2315                         command=['git', 'fetch', '-t',
 2316                                  'http://github.com/buildbot/buildbot.git',
 2317                                  'HEAD'])
 2318             + 0,
 2319             ExpectShell(workdir='source',
 2320                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2321             + 0,
 2322             Expect('cpdir', {'fromdir': 'source', 'todir': 'wkdir',
 2323                              'logEnviron': True, 'timeout': 1200})
 2324             + 0,
 2325             ExpectShell(workdir='wkdir',
 2326                         command=['git', 'rev-parse', 'HEAD'])
 2327             + ExpectShell.log('stdio',
 2328                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2329             + 0,
 2330         )
 2331         self.expectOutcome(result=SUCCESS)
 2332         self.expectProperty(
 2333             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2334         return self.runStep()
 2335 
 2336     def test_mode_full_copy_ssh_key_2_10(self):
 2337         self.setupStep(
 2338             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2339                            mode='full', method='copy', sshPrivateKey='sshkey'))
 2340 
 2341         ssh_workdir = '/wrk/.source.buildbot'
 2342         ssh_key_path = '/wrk/.source.buildbot/ssh-key'
 2343         ssh_command_config = \
 2344             'core.sshCommand=ssh -i "{0}"'.format(ssh_key_path)
 2345 
 2346         self.expectCommands(
 2347             ExpectShell(workdir='wkdir',
 2348                         command=['git', '--version'])
 2349             + ExpectShell.log('stdio',
 2350                               stdout='git version 2.10.0')
 2351             + 0,
 2352             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2353                                 logEnviron=True))
 2354             + 1,
 2355             Expect('mkdir', dict(dir=ssh_workdir,
 2356                                  logEnviron=True))
 2357             + 0,
 2358             Expect('downloadFile', dict(blocksize=32768, maxsize=None,
 2359                                         reader=ExpectRemoteRef(
 2360                                             remotetransfer.StringFileReader),
 2361                                         workerdest=ssh_key_path,
 2362                                         workdir='source',
 2363                                         mode=0o400))
 2364             + 0,
 2365             Expect('rmdir', dict(dir='wkdir',
 2366                                  logEnviron=True,
 2367                                  timeout=1200)),
 2368             Expect('listdir', {'dir': 'source', 'logEnviron': True,
 2369                                'timeout': 1200})
 2370             + Expect.update('files', ['.git'])
 2371             + 0,
 2372             ExpectShell(workdir='source',
 2373                         command=['git', '-c', ssh_command_config,
 2374                                  'fetch', '-t',
 2375                                  'http://github.com/buildbot/buildbot.git',
 2376                                  'HEAD'])
 2377             + 0,
 2378             ExpectShell(workdir='source',
 2379                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2380             + 0,
 2381             Expect('cpdir', {'fromdir': 'source', 'todir': 'wkdir',
 2382                              'logEnviron': True, 'timeout': 1200})
 2383             + 0,
 2384             ExpectShell(workdir='wkdir',
 2385                         command=['git', 'rev-parse', 'HEAD'])
 2386             + ExpectShell.log('stdio',
 2387                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2388             + 0,
 2389             Expect('rmdir', dict(dir=ssh_workdir,
 2390                                  logEnviron=True))
 2391             + 0,
 2392         )
 2393         self.expectOutcome(result=SUCCESS)
 2394         self.expectProperty(
 2395             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2396         return self.runStep()
 2397 
 2398     def test_mode_full_copy_shallow(self):
 2399         with self.assertRaisesConfigError(
 2400                 "shallow only possible with mode 'full' and method 'clobber'"):
 2401             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2402                         mode='full', method='copy', shallow=True)
 2403 
 2404     def test_mode_incremental_no_existing_repo(self):
 2405         self.setupStep(
 2406             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2407                            mode='incremental'))
 2408         self.expectCommands(
 2409             ExpectShell(workdir='wkdir',
 2410                         command=['git', '--version'])
 2411             + ExpectShell.log('stdio',
 2412                               stdout='git version 1.7.5')
 2413             + 0,
 2414             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2415                                 logEnviron=True))
 2416             + 1,
 2417             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2418                                'timeout': 1200})
 2419             + Expect.update('files', [])
 2420             + 0,
 2421             ExpectShell(workdir='wkdir',
 2422                         command=['git', 'clone',
 2423                                  'http://github.com/buildbot/buildbot.git', '.'])
 2424             + 0,
 2425             ExpectShell(workdir='wkdir',
 2426                         command=['git', 'rev-parse', 'HEAD'])
 2427             + ExpectShell.log('stdio',
 2428                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2429             + 0,
 2430 
 2431         )
 2432         self.expectOutcome(result=SUCCESS)
 2433         self.expectProperty(
 2434             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2435         return self.runStep()
 2436 
 2437     def test_mode_incremental_no_existing_repo_oldworker(self):
 2438         self.setupStep(
 2439             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2440                            mode='incremental'))
 2441         self.step.build.getWorkerCommandVersion = lambda cmd, oldversion: "2.15"
 2442         self.expectCommands(
 2443             ExpectShell(workdir='wkdir',
 2444                         command=['git', '--version'])
 2445             + ExpectShell.log('stdio',
 2446                               stdout='git version 1.7.5')
 2447             + 0,
 2448             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2449                                 logEnviron=True))
 2450             + 1,
 2451             Expect('stat', dict(file='wkdir/.git',
 2452                                 logEnviron=True))
 2453             + 1,
 2454             ExpectShell(workdir='wkdir',
 2455                         command=['git', 'clone',
 2456                                  'http://github.com/buildbot/buildbot.git', '.'])
 2457             + 0,
 2458             ExpectShell(workdir='wkdir',
 2459                         command=['git', 'rev-parse', 'HEAD'])
 2460             + ExpectShell.log('stdio',
 2461                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2462             + 0,
 2463 
 2464         )
 2465         self.expectOutcome(result=SUCCESS)
 2466         self.expectProperty(
 2467             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2468         return self.runStep()
 2469 
 2470     def test_mode_full_clobber_given_revision(self):
 2471         self.setupStep(
 2472             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2473                            mode='full', method='clobber', progress=True), dict(
 2474                 revision='abcdef01',
 2475             ))
 2476         self.expectCommands(
 2477             ExpectShell(workdir='wkdir',
 2478                         command=['git', '--version'])
 2479             + ExpectShell.log('stdio',
 2480                               stdout='git version 1.7.5')
 2481             + 0,
 2482             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2483                                 logEnviron=True))
 2484             + 1,
 2485             Expect('rmdir', dict(dir='wkdir',
 2486                                  logEnviron=True,
 2487                                  timeout=1200))
 2488             + 0,
 2489             ExpectShell(workdir='wkdir',
 2490                         command=['git', 'clone',
 2491                                  'http://github.com/buildbot/buildbot.git',
 2492                                  '.', '--progress'])
 2493             + 0,
 2494             ExpectShell(workdir='wkdir',
 2495                         command=['git', 'reset', '--hard', 'abcdef01', '--'])
 2496             + 0,
 2497             ExpectShell(workdir='wkdir',
 2498                         command=['git', 'rev-parse', 'HEAD'])
 2499             + ExpectShell.log('stdio',
 2500                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2501             + 0,
 2502         )
 2503         self.expectOutcome(result=SUCCESS)
 2504         self.expectProperty(
 2505             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2506         return self.runStep()
 2507 
 2508     def test_revparse_failure(self):
 2509         self.setupStep(
 2510             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2511                            mode='full', method='clobber', progress=True), dict(
 2512                 revision='abcdef01',
 2513             ))
 2514         self.expectCommands(
 2515             ExpectShell(workdir='wkdir',
 2516                         command=['git', '--version'])
 2517             + ExpectShell.log('stdio',
 2518                               stdout='git version 1.7.5')
 2519             + 0,
 2520             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2521                                 logEnviron=True))
 2522             + 1,
 2523             Expect('rmdir', dict(dir='wkdir',
 2524                                  logEnviron=True,
 2525                                  timeout=1200))
 2526             + 0,
 2527             ExpectShell(workdir='wkdir',
 2528                         command=['git', 'clone',
 2529                                  'http://github.com/buildbot/buildbot.git',
 2530                                  '.', '--progress'])
 2531             + 0,
 2532             ExpectShell(workdir='wkdir',
 2533                         command=['git', 'reset', '--hard', 'abcdef01', '--'])
 2534             + 0,
 2535             ExpectShell(workdir='wkdir',
 2536                         command=['git', 'rev-parse', 'HEAD'])
 2537             + ExpectShell.log('stdio',
 2538                               stdout='f6ada95a1d')  # too short
 2539             + 0,
 2540         )
 2541         self.expectOutcome(result=FAILURE)
 2542         self.expectNoProperty('got_revision')
 2543         return self.runStep()
 2544 
 2545     def test_mode_full_clobber_submodule(self):
 2546         self.setupStep(
 2547             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2548                            mode='full', method='clobber', submodules=True))
 2549 
 2550         self.expectCommands(
 2551             ExpectShell(workdir='wkdir',
 2552                         command=['git', '--version'])
 2553             + ExpectShell.log('stdio',
 2554                               stdout='git version 1.7.5')
 2555             + 0,
 2556             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2557                                 logEnviron=True))
 2558             + 1,
 2559             Expect('rmdir', dict(dir='wkdir',
 2560                                  logEnviron=True,
 2561                                  timeout=1200))
 2562             + 0,
 2563             ExpectShell(workdir='wkdir',
 2564                         command=['git', 'clone',
 2565                                  'http://github.com/buildbot/buildbot.git', '.'])
 2566             + 0,
 2567             ExpectShell(workdir='wkdir',
 2568                         command=['git', 'submodule', 'update',
 2569                                  '--init', '--recursive'])
 2570             + 0,
 2571             ExpectShell(workdir='wkdir',
 2572                         command=['git', 'rev-parse', 'HEAD'])
 2573             + ExpectShell.log('stdio',
 2574                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2575             + 0,
 2576         )
 2577         self.expectOutcome(result=SUCCESS)
 2578         self.expectProperty(
 2579             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2580         return self.runStep()
 2581 
 2582     def test_repourl(self):
 2583         with self.assertRaisesConfigError("must provide repourl"):
 2584             self.stepClass(mode="full")
 2585 
 2586     def test_mode_full_fresh_revision(self):
 2587         self.setupStep(
 2588             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2589                            mode='full', method='fresh', progress=True), dict(
 2590                 revision='abcdef01',
 2591             ))
 2592         self.expectCommands(
 2593             ExpectShell(workdir='wkdir',
 2594                         command=['git', '--version'])
 2595             + ExpectShell.log('stdio',
 2596                               stdout='git version 1.7.5')
 2597             + 0,
 2598             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2599                                 logEnviron=True))
 2600             + 1,
 2601             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2602                                'timeout': 1200})
 2603             + Expect.update('files', [])
 2604             + 0,
 2605             ExpectShell(workdir='wkdir',
 2606                         command=['git', 'clone',
 2607                                  'http://github.com/buildbot/buildbot.git',
 2608                                  '.', '--progress'])
 2609             + 0,
 2610             ExpectShell(workdir='wkdir',
 2611                         command=['git', 'reset', '--hard', 'abcdef01', '--'])
 2612             + 0,
 2613             ExpectShell(workdir='wkdir',
 2614                         command=['git', 'rev-parse', 'HEAD'])
 2615             + ExpectShell.log('stdio',
 2616                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2617             + 0,
 2618         )
 2619         self.expectOutcome(result=SUCCESS)
 2620         self.expectProperty(
 2621             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2622         return self.runStep()
 2623 
 2624     def test_mode_full_fresh_retry(self):
 2625         self.setupStep(
 2626             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2627                            mode='full', method='fresh', retry=(0, 2)))
 2628         self.expectCommands(
 2629             ExpectShell(workdir='wkdir',
 2630                         command=['git', '--version'])
 2631             + ExpectShell.log('stdio',
 2632                               stdout='git version 1.7.5')
 2633             + 0,
 2634             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2635                                 logEnviron=True))
 2636             + 1,
 2637             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2638                                'timeout': 1200})
 2639             + Expect.update('files', [])
 2640             + 0,
 2641             ExpectShell(workdir='wkdir',
 2642                         command=['git', 'clone',
 2643                                  'http://github.com/buildbot/buildbot.git', '.'])
 2644             + 1,
 2645             Expect('rmdir', dict(dir='wkdir',
 2646                                  logEnviron=True,
 2647                                  timeout=1200))
 2648             + 0,
 2649             ExpectShell(workdir='wkdir',
 2650                         command=['git', 'clone',
 2651                                  'http://github.com/buildbot/buildbot.git',
 2652                                  '.'])
 2653             + 1,
 2654             Expect('rmdir', dict(dir='wkdir',
 2655                                  logEnviron=True,
 2656                                  timeout=1200))
 2657             + 0,
 2658             ExpectShell(workdir='wkdir',
 2659                         command=['git', 'clone',
 2660                                  'http://github.com/buildbot/buildbot.git',
 2661                                  '.'])
 2662             + 0,
 2663             ExpectShell(workdir='wkdir',
 2664                         command=['git', 'rev-parse', 'HEAD'])
 2665             + ExpectShell.log('stdio',
 2666                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2667             + 0,
 2668         )
 2669         self.expectOutcome(result=SUCCESS)
 2670         self.expectProperty(
 2671             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2672         return self.runStep()
 2673 
 2674     def test_mode_full_fresh_clobberOnFailure(self):
 2675         self.setupStep(
 2676             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2677                            mode='full', method='fresh', clobberOnFailure=True))
 2678 
 2679         self.expectCommands(
 2680             ExpectShell(workdir='wkdir',
 2681                         command=['git', '--version'])
 2682             + ExpectShell.log('stdio',
 2683                               stdout='git version 1.7.5')
 2684             + 0,
 2685             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2686                                 logEnviron=True))
 2687             + 1,
 2688             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2689                                'timeout': 1200})
 2690             + Expect.update('files', [])
 2691             + 0,
 2692             ExpectShell(workdir='wkdir',
 2693                         command=['git', 'clone',
 2694                                  'http://github.com/buildbot/buildbot.git', '.'])
 2695             + 1,
 2696             Expect('rmdir', dict(dir='wkdir',
 2697                                  logEnviron=True,
 2698                                  timeout=1200))
 2699             + 0,
 2700             ExpectShell(workdir='wkdir',
 2701                         command=['git', 'clone',
 2702                                  'http://github.com/buildbot/buildbot.git',
 2703                                  '.'])
 2704             + 0,
 2705             ExpectShell(workdir='wkdir',
 2706                         command=['git', 'rev-parse', 'HEAD'])
 2707             + ExpectShell.log('stdio',
 2708                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2709             + 0,
 2710         )
 2711         self.expectOutcome(result=SUCCESS)
 2712         self.expectProperty(
 2713             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2714         return self.runStep()
 2715 
 2716     def test_mode_full_no_method(self):
 2717         self.setupStep(
 2718             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2719                            mode='full'))
 2720         self.expectCommands(
 2721             ExpectShell(workdir='wkdir',
 2722                         command=['git', '--version'])
 2723             + ExpectShell.log('stdio',
 2724                               stdout='git version 1.7.5')
 2725             + 0,
 2726             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2727                                 logEnviron=True))
 2728             + 1,
 2729             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2730                                'timeout': 1200})
 2731             + Expect.update('files', ['.git'])
 2732             + 0,
 2733             ExpectShell(workdir='wkdir',
 2734                         command=['git', 'clean', '-f', '-f', '-d', '-x'])
 2735             + 0,
 2736             ExpectShell(workdir='wkdir',
 2737                         command=['git', 'fetch', '-t',
 2738                                  'http://github.com/buildbot/buildbot.git',
 2739                                  'HEAD'])
 2740             + 0,
 2741             ExpectShell(workdir='wkdir',
 2742                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2743             + 0,
 2744             ExpectShell(workdir='wkdir',
 2745                         command=['git', 'rev-parse', 'HEAD'])
 2746             + ExpectShell.log('stdio',
 2747                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2748             + 0,
 2749         )
 2750         self.expectOutcome(result=SUCCESS)
 2751         self.expectProperty(
 2752             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2753         return self.runStep()
 2754 
 2755     def test_mode_full_with_env(self):
 2756         self.setupStep(
 2757             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2758                            mode='full', env={'abc': '123'}))
 2759         self.expectCommands(
 2760             ExpectShell(workdir='wkdir',
 2761                         command=['git', '--version'],
 2762                         env={'abc': '123'})
 2763             + ExpectShell.log('stdio',
 2764                               stdout='git version 1.7.5')
 2765             + 0,
 2766             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2767                                 logEnviron=True))
 2768             + 1,
 2769             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2770                                'timeout': 1200})
 2771             + Expect.update('files', ['.git'])
 2772             + 0,
 2773             ExpectShell(workdir='wkdir',
 2774                         command=['git', 'clean', '-f', '-f', '-d', '-x'],
 2775                         env={'abc': '123'})
 2776             + 0,
 2777             ExpectShell(workdir='wkdir',
 2778                         command=['git', 'fetch', '-t',
 2779                                  'http://github.com/buildbot/buildbot.git',
 2780                                  'HEAD'],
 2781                         env={'abc': '123'})
 2782             + 0,
 2783             ExpectShell(workdir='wkdir',
 2784                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'],
 2785                         env={'abc': '123'})
 2786             + 0,
 2787             ExpectShell(workdir='wkdir',
 2788                         command=['git', 'rev-parse', 'HEAD'],
 2789                         env={'abc': '123'})
 2790             + ExpectShell.log('stdio',
 2791                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2792             + 0,
 2793         )
 2794         self.expectOutcome(result=SUCCESS)
 2795         self.expectProperty(
 2796             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2797         return self.runStep()
 2798 
 2799     def test_mode_full_logEnviron(self):
 2800         self.setupStep(
 2801             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2802                            mode='full', logEnviron=False))
 2803         self.expectCommands(
 2804             ExpectShell(workdir='wkdir',
 2805                         command=['git', '--version'],
 2806                         logEnviron=False)
 2807             + ExpectShell.log('stdio',
 2808                               stdout='git version 1.7.5')
 2809             + 0,
 2810             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2811                                 logEnviron=False))
 2812             + 1,
 2813             Expect('listdir', {'dir': 'wkdir', 'logEnviron': False,
 2814                                'timeout': 1200})
 2815             + Expect.update('files', ['.git'])
 2816             + 0,
 2817             ExpectShell(workdir='wkdir',
 2818                         command=['git', 'clean', '-f', '-f', '-d', '-x'],
 2819                         logEnviron=False)
 2820             + 0,
 2821             ExpectShell(workdir='wkdir',
 2822                         command=['git', 'fetch', '-t',
 2823                                  'http://github.com/buildbot/buildbot.git',
 2824                                  'HEAD'],
 2825                         logEnviron=False)
 2826             + 0,
 2827             ExpectShell(workdir='wkdir',
 2828                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'],
 2829                         logEnviron=False)
 2830             + 0,
 2831             ExpectShell(workdir='wkdir',
 2832                         command=['git', 'rev-parse', 'HEAD'],
 2833                         logEnviron=False)
 2834             + ExpectShell.log('stdio',
 2835                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2836             + 0,
 2837         )
 2838         self.expectOutcome(result=SUCCESS)
 2839         self.expectProperty(
 2840             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2841         return self.runStep()
 2842 
 2843     def test_wkdir_doesnt_exist(self):
 2844         self.setupStep(
 2845             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2846                            mode='full'))
 2847         self.expectCommands(
 2848             ExpectShell(workdir='wkdir',
 2849                         command=['git', '--version'])
 2850             + ExpectShell.log('stdio',
 2851                               stdout='git version 1.7.5')
 2852             + 0,
 2853             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2854                                 logEnviron=True))
 2855             + 1,
 2856             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2857                                'timeout': 1200})
 2858             + 1,
 2859             ExpectShell(workdir='wkdir',
 2860                         command=['git', 'clone',
 2861                                  'http://github.com/buildbot/buildbot.git',
 2862                                  '.'])
 2863             + 0,
 2864             ExpectShell(workdir='wkdir',
 2865                         command=['git', 'rev-parse', 'HEAD'])
 2866             + ExpectShell.log('stdio',
 2867                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2868             + 0,
 2869         )
 2870         self.expectOutcome(result=SUCCESS)
 2871         self.expectProperty(
 2872             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2873         return self.runStep()
 2874 
 2875     def test_getDescription(self):
 2876         # clone of: test_mode_incremental
 2877         # only difference is to set the getDescription property
 2878 
 2879         self.setupStep(
 2880             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2881                            mode='incremental',
 2882                            getDescription=True))
 2883         self.expectCommands(
 2884             # copied from test_mode_incremental:
 2885             ExpectShell(workdir='wkdir',
 2886                         command=['git', '--version'])
 2887             + ExpectShell.log('stdio',
 2888                               stdout='git version 1.7.5')
 2889             + 0,
 2890             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2891                                 logEnviron=True))
 2892             + 1,
 2893             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2894                                'timeout': 1200})
 2895             + Expect.update('files', ['.git'])
 2896             + 0,
 2897             ExpectShell(workdir='wkdir',
 2898                         command=['git', 'fetch', '-t',
 2899                                  'http://github.com/buildbot/buildbot.git',
 2900                                  'HEAD'])
 2901             + 0,
 2902             ExpectShell(workdir='wkdir',
 2903                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2904             + 0,
 2905             ExpectShell(workdir='wkdir',
 2906                         command=['git', 'rev-parse', 'HEAD'])
 2907             + ExpectShell.log('stdio',
 2908                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2909             + 0,
 2910 
 2911             # plus this to test describe:
 2912             ExpectShell(workdir='wkdir',
 2913                         command=['git', 'describe', 'HEAD'])
 2914             + ExpectShell.log('stdio',
 2915                               stdout='Tag-1234')
 2916             + 0,
 2917         )
 2918         self.expectOutcome(result=SUCCESS)
 2919         self.expectProperty(
 2920             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2921         self.expectProperty('commit-description', 'Tag-1234', self.sourceName)
 2922         return self.runStep()
 2923 
 2924     def test_getDescription_failed(self):
 2925         # clone of: test_mode_incremental
 2926         # only difference is to set the getDescription property
 2927 
 2928         # this tests when 'git describe' fails; for example, there are no
 2929         # tags in the repository
 2930 
 2931         self.setupStep(
 2932             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2933                            mode='incremental',
 2934                            getDescription=True))
 2935         self.expectCommands(
 2936             # copied from test_mode_incremental:
 2937             ExpectShell(workdir='wkdir',
 2938                         command=['git', '--version'])
 2939             + ExpectShell.log('stdio',
 2940                               stdout='git version 1.7.5')
 2941             + 0,
 2942             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2943                                 logEnviron=True))
 2944             + 1,
 2945             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 2946                                'timeout': 1200})
 2947             + Expect.update('files', ['.git'])
 2948             + 0,
 2949             ExpectShell(workdir='wkdir',
 2950                         command=['git', 'fetch', '-t',
 2951                                  'http://github.com/buildbot/buildbot.git',
 2952                                  'HEAD'])
 2953             + 0,
 2954             ExpectShell(workdir='wkdir',
 2955                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
 2956             + 0,
 2957             ExpectShell(workdir='wkdir',
 2958                         command=['git', 'rev-parse', 'HEAD'])
 2959             + ExpectShell.log('stdio',
 2960                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 2961             + 0,
 2962 
 2963             # plus this to test describe:
 2964             ExpectShell(workdir='wkdir',
 2965                         command=['git', 'describe', 'HEAD'])
 2966             + ExpectShell.log('stdio',
 2967                               stdout='')
 2968             + 128,  # error, but it's suppressed
 2969         )
 2970         self.expectOutcome(result=SUCCESS)
 2971         self.expectProperty(
 2972             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 2973         self.expectNoProperty('commit-description')
 2974         return self.runStep()
 2975 
 2976     def setup_getDescription_test(self, setup_args, output_args,
 2977                                   expect_head=True, codebase=None):
 2978         # clone of: test_mode_full_clobber
 2979         # only difference is to set the getDescription property
 2980 
 2981         kwargs = {}
 2982         if codebase is not None:
 2983             kwargs.update(codebase=codebase)
 2984 
 2985         self.setupStep(
 2986             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 2987                            mode='full', method='clobber', progress=True,
 2988                            getDescription=setup_args,
 2989                            **kwargs))
 2990 
 2991         self.expectCommands(
 2992             # copied from test_mode_full_clobber:
 2993             ExpectShell(workdir='wkdir',
 2994                         command=['git', '--version'])
 2995             + ExpectShell.log('stdio',
 2996                               stdout='git version 1.7.5')
 2997             + 0,
 2998             Expect('stat', dict(file='wkdir/.buildbot-patched',
 2999                                 logEnviron=True))
 3000             + 1,
 3001             Expect('rmdir', dict(dir='wkdir',
 3002                                  logEnviron=True,
 3003                                  timeout=1200))
 3004             + 0,
 3005             ExpectShell(workdir='wkdir',
 3006                         command=['git', 'clone',
 3007                                  'http://github.com/buildbot/buildbot.git',
 3008                                  '.', '--progress'])
 3009             + 0,
 3010             ExpectShell(workdir='wkdir',
 3011                         command=['git', 'rev-parse', 'HEAD'])
 3012             + ExpectShell.log('stdio',
 3013                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 3014             + 0,
 3015 
 3016             # plus this to test describe:
 3017             ExpectShell(workdir='wkdir',
 3018                         command=['git', 'describe'] +
 3019                                 output_args +
 3020                                 (['HEAD'] if expect_head else []))
 3021             + ExpectShell.log('stdio',
 3022                               stdout='Tag-1234')
 3023             + 0,
 3024         )
 3025 
 3026         if codebase:
 3027             self.expectOutcome(result=SUCCESS,
 3028                                state_string="update " + codebase)
 3029             self.expectProperty(
 3030                 'got_revision', {codebase: 'f6ad368298bd941e934a41f3babc827b2aa95a1d'}, self.sourceName)
 3031             self.expectProperty(
 3032                 'commit-description', {codebase: 'Tag-1234'}, self.sourceName)
 3033         else:
 3034             self.expectOutcome(result=SUCCESS,
 3035                                state_string="update")
 3036             self.expectProperty(
 3037                 'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', self.sourceName)
 3038             self.expectProperty('commit-description', 'Tag-1234', self.sourceName)
 3039 
 3040     def test_getDescription_empty_dict(self):
 3041         self.setup_getDescription_test(
 3042             setup_args={},
 3043             output_args=[]
 3044         )
 3045         return self.runStep()
 3046 
 3047     def test_getDescription_empty_dict_with_codebase(self):
 3048         self.setup_getDescription_test(
 3049             setup_args={},
 3050             output_args=[],
 3051             codebase='baz'
 3052         )
 3053         return self.runStep()
 3054 
 3055     def test_getDescription_match(self):
 3056         self.setup_getDescription_test(
 3057             setup_args={'match': 'stuff-*'},
 3058             output_args=['--match', 'stuff-*']
 3059         )
 3060         return self.runStep()
 3061 
 3062     def test_getDescription_match_false(self):
 3063         self.setup_getDescription_test(
 3064             setup_args={'match': None},
 3065             output_args=[]
 3066         )
 3067         return self.runStep()
 3068 
 3069     def test_getDescription_tags(self):
 3070         self.setup_getDescription_test(
 3071             setup_args={'tags': True},
 3072             output_args=['--tags']
 3073         )
 3074         return self.runStep()
 3075 
 3076     def test_getDescription_tags_false(self):
 3077         self.setup_getDescription_test(
 3078             setup_args={'tags': False},
 3079             output_args=[]
 3080         )
 3081         return self.runStep()
 3082 
 3083     def test_getDescription_all(self):
 3084         self.setup_getDescription_test(
 3085             setup_args={'all': True},
 3086             output_args=['--all']
 3087         )
 3088         return self.runStep()
 3089 
 3090     def test_getDescription_all_false(self):
 3091         self.setup_getDescription_test(
 3092             setup_args={'all': False},
 3093             output_args=[]
 3094         )
 3095         return self.runStep()
 3096 
 3097     def test_getDescription_abbrev(self):
 3098         self.setup_getDescription_test(
 3099             setup_args={'abbrev': 7},
 3100             output_args=['--abbrev=7']
 3101         )
 3102         return self.runStep()
 3103 
 3104     def test_getDescription_abbrev_zero(self):
 3105         self.setup_getDescription_test(
 3106             setup_args={'abbrev': 0},
 3107             output_args=['--abbrev=0']
 3108         )
 3109         return self.runStep()
 3110 
 3111     def test_getDescription_abbrev_false(self):
 3112         self.setup_getDescription_test(
 3113             setup_args={'abbrev': False},
 3114             output_args=[]
 3115         )
 3116         return self.runStep()
 3117 
 3118     def test_getDescription_dirty(self):
 3119         self.setup_getDescription_test(
 3120             setup_args={'dirty': True},
 3121             output_args=['--dirty'],
 3122             expect_head=False
 3123         )
 3124         return self.runStep()
 3125 
 3126     def test_getDescription_dirty_empty_str(self):
 3127         self.setup_getDescription_test(
 3128             setup_args={'dirty': ''},
 3129             output_args=['--dirty'],
 3130             expect_head=False
 3131         )
 3132         return self.runStep()
 3133 
 3134     def test_getDescription_dirty_str(self):
 3135         self.setup_getDescription_test(
 3136             setup_args={'dirty': 'foo'},
 3137             output_args=['--dirty=foo'],
 3138             expect_head=False
 3139         )
 3140         return self.runStep()
 3141 
 3142     def test_getDescription_dirty_false(self):
 3143         self.setup_getDescription_test(
 3144             setup_args={'dirty': False},
 3145             output_args=[],
 3146             expect_head=True
 3147         )
 3148         return self.runStep()
 3149 
 3150     def test_getDescription_dirty_none(self):
 3151         self.setup_getDescription_test(
 3152             setup_args={'dirty': None},
 3153             output_args=[],
 3154             expect_head=True
 3155         )
 3156         return self.runStep()
 3157 
 3158     def test_getDescription_contains(self):
 3159         self.setup_getDescription_test(
 3160             setup_args={'contains': True},
 3161             output_args=['--contains']
 3162         )
 3163         return self.runStep()
 3164 
 3165     def test_getDescription_contains_false(self):
 3166         self.setup_getDescription_test(
 3167             setup_args={'contains': False},
 3168             output_args=[]
 3169         )
 3170         return self.runStep()
 3171 
 3172     def test_getDescription_candidates(self):
 3173         self.setup_getDescription_test(
 3174             setup_args={'candidates': 7},
 3175             output_args=['--candidates=7']
 3176         )
 3177         return self.runStep()
 3178 
 3179     def test_getDescription_candidates_zero(self):
 3180         self.setup_getDescription_test(
 3181             setup_args={'candidates': 0},
 3182             output_args=['--candidates=0']
 3183         )
 3184         return self.runStep()
 3185 
 3186     def test_getDescription_candidates_false(self):
 3187         self.setup_getDescription_test(
 3188             setup_args={'candidates': False},
 3189             output_args=[]
 3190         )
 3191         return self.runStep()
 3192 
 3193     def test_getDescription_exact_match(self):
 3194         self.setup_getDescription_test(
 3195             setup_args={'exact-match': True},
 3196             output_args=['--exact-match']
 3197         )
 3198         return self.runStep()
 3199 
 3200     def test_getDescription_exact_match_false(self):
 3201         self.setup_getDescription_test(
 3202             setup_args={'exact-match': False},
 3203             output_args=[]
 3204         )
 3205         return self.runStep()
 3206 
 3207     def test_getDescription_debug(self):
 3208         self.setup_getDescription_test(
 3209             setup_args={'debug': True},
 3210             output_args=['--debug']
 3211         )
 3212         return self.runStep()
 3213 
 3214     def test_getDescription_debug_false(self):
 3215         self.setup_getDescription_test(
 3216             setup_args={'debug': False},
 3217             output_args=[]
 3218         )
 3219         return self.runStep()
 3220 
 3221     def test_getDescription_long(self):
 3222         self.setup_getDescription_test(
 3223             setup_args={'long': True},
 3224             output_args=['--long']
 3225         )
 3226 
 3227     def test_getDescription_long_false(self):
 3228         self.setup_getDescription_test(
 3229             setup_args={'long': False},
 3230             output_args=[]
 3231         )
 3232         return self.runStep()
 3233 
 3234     def test_getDescription_always(self):
 3235         self.setup_getDescription_test(
 3236             setup_args={'always': True},
 3237             output_args=['--always']
 3238         )
 3239 
 3240     def test_getDescription_always_false(self):
 3241         self.setup_getDescription_test(
 3242             setup_args={'always': False},
 3243             output_args=[]
 3244         )
 3245         return self.runStep()
 3246 
 3247     def test_getDescription_lotsa_stuff(self):
 3248         self.setup_getDescription_test(
 3249             setup_args={'match': 'stuff-*',
 3250                         'abbrev': 6,
 3251                         'exact-match': True},
 3252             output_args=['--exact-match',
 3253                          '--match', 'stuff-*',
 3254                          '--abbrev=6'],
 3255             codebase='baz'
 3256         )
 3257         return self.runStep()
 3258 
 3259     def test_config_option(self):
 3260         name = 'url.http://github.com.insteadOf'
 3261         value = 'blahblah'
 3262         self.setupStep(
 3263             self.stepClass(repourl='%s/buildbot/buildbot.git' % (value,),
 3264                            mode='full', method='clean',
 3265                            config={name: value}))
 3266         prefix = ['git', '-c', '%s=%s' % (name, value)]
 3267         self.expectCommands(
 3268             ExpectShell(workdir='wkdir',
 3269                         command=prefix + ['--version'])
 3270             + ExpectShell.log('stdio',
 3271                               stdout='git version 1.7.5')
 3272             + 0,
 3273             Expect('stat', dict(file='wkdir/.buildbot-patched',
 3274                                 logEnviron=True))
 3275             + 1,
 3276             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
 3277                                'timeout': 1200})
 3278             + Expect.update('files', ['.git'])
 3279             + 0,
 3280             ExpectShell(workdir='wkdir',
 3281                         command=prefix + ['clean', '-f', '-f', '-d'])
 3282             + 0,
 3283             ExpectShell(workdir='wkdir',
 3284                         command=prefix + ['fetch', '-t',
 3285                                           '%s/buildbot/buildbot.git' % (
 3286                                               value,),
 3287                                           'HEAD'])
 3288             + 0,
 3289             ExpectShell(workdir='wkdir',
 3290                         command=prefix + ['reset', '--hard',
 3291                                           'FETCH_HEAD', '--'])
 3292             + 0,
 3293             ExpectShell(workdir='wkdir',
 3294                         command=prefix + ['rev-parse', 'HEAD'])
 3295             + ExpectShell.log('stdio',
 3296                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
 3297             + 0,
 3298         )
 3299         self.expectOutcome(result=SUCCESS)
 3300         return self.runStep()
 3301 
 3302     def test_worker_connection_lost(self):
 3303         self.setupStep(
 3304             self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 3305                            mode='full', method='clean'))
 3306         self.expectCommands(
 3307             ExpectShell(workdir='wkdir',
 3308                         command=['git', '--version'])
 3309             + ExpectShell.log('stdio',
 3310                               stdout='git version 1.7.5')
 3311             + ('err', error.ConnectionLost())
 3312         )
 3313         self.expectOutcome(result=RETRY, state_string="update (retry)")
 3314         return self.runStep()
 3315 
 3316     def _test_WorkerTooOldError(self, _dovccmd, step, msg):
 3317         def check(failure):
 3318             self.assertIsInstance(failure.value, WorkerTooOldError)
 3319             self.assertEqual(str(failure.value), msg)
 3320 
 3321         self.patch(self.stepClass, "_dovccmd", _dovccmd)
 3322         gitStep = self.setupStep(step)
 3323 
 3324         gitStep._start_deferred = defer.Deferred()
 3325         gitStep.startVC("branch", "revision", "patch")
 3326         d = gitStep._start_deferred.addBoth(check)
 3327         return d
 3328 
 3329     def test_noGitCommandInstalled(self):
 3330         @defer.inlineCallbacks
 3331         def _dovccmd(command, abandonOnFailure=True, collectStdout=False,
 3332                      initialStdin=None):
 3333             """
 3334             Simulate the case where there is no git command.
 3335             """
 3336             yield
 3337             return "command not found:"
 3338 
 3339         step = self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 3340                               mode='full', method='clean')
 3341         msg = 'git is not installed on worker'
 3342         return self._test_WorkerTooOldError(_dovccmd, step, msg)
 3343 
 3344     def test_gitCommandOutputShowsNoVersion(self):
 3345         @defer.inlineCallbacks
 3346         def _dovccmd(command, abandonOnFailure=True, collectStdout=False,
 3347                      initialStdin=None):
 3348             """
 3349             Instead of outputting something like "git version 2.11",
 3350             simulate truncated output which has no version string,
 3351             to exercise error handling.
 3352             """
 3353             yield
 3354             return "git "
 3355 
 3356         step = self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
 3357                               mode='full', method='clean')
 3358         msg = 'git is not installed on worker'
 3359         return self._test_WorkerTooOldError(_dovccmd, step, msg)
 3360 
 3361     def test_config_get_description_not_dict_or_boolean(self):
 3362         with self.assertRaisesConfigError("Git: getDescription must be a boolean or a dict."):
 3363             self.stepClass(repourl="http://github.com/buildbot/buildbot.git",
 3364                            getDescription=["list"])
 3365 
 3366     def test_config_invalid_method_with_full(self):
 3367         with self.assertRaisesConfigError("Git: invalid method for mode 'full'."):
 3368             self.stepClass(repourl="http://github.com/buildbot/buildbot.git",
 3369                            mode='full', method='unknown')
 3370 
 3371 
 3372 class TestGitPush(steps.BuildStepMixin, config.ConfigErrorsMixin,
 3373                   TestReactorMixin,
 3374                   unittest.TestCase):
 3375     stepClass = git.GitPush
 3376 
 3377     def setUp(self):
 3378         self.setUpTestReactor()
 3379         return self.setUpBuildStep()
 3380 
 3381     def tearDown(self):
 3382         return self.tearDownBuildStep()
 3383 
 3384     def test_push_simple(self):
 3385         url = 'ssh://github.com/test/test.git'
 3386 
 3387         self.setupStep(
 3388             self.stepClass(workdir='wkdir', repourl=url,
 3389                            branch='testbranch'))
 3390         self.expectCommands(
 3391             ExpectShell(workdir='wkdir',
 3392                         command=['git', '--version'])
 3393             + ExpectShell.log('stdio',
 3394                               stdout='git version 1.7.5')
 3395             + 0,
 3396             ExpectShell(workdir='wkdir',
 3397                         command=['git', 'push', url, 'testbranch'])
 3398             + 0,
 3399         )
 3400         self.expectOutcome(result=SUCCESS)
 3401         return self.runStep()
 3402 
 3403     def test_push_force(self):
 3404         url = 'ssh://github.com/test/test.git'
 3405 
 3406         self.setupStep(
 3407             self.stepClass(workdir='wkdir', repourl=url,
 3408                            branch='testbranch', force=True))
 3409         self.expectCommands(
 3410             ExpectShell(workdir='wkdir',
 3411                         command=['git', '--version'])
 3412             + ExpectShell.log('stdio',
 3413                               stdout='git version 1.7.5')
 3414             + 0,
 3415             ExpectShell(workdir='wkdir',
 3416                         command=['git', 'push', url, 'testbranch', '--force'])
 3417             + 0,
 3418         )
 3419         self.expectOutcome(result=SUCCESS)
 3420         return self.runStep()
 3421 
 3422     def test_push_fail(self):
 3423         url = 'ssh://github.com/test/test.git'
 3424 
 3425         self.setupStep(
 3426             self.stepClass(workdir='wkdir', repourl=url,
 3427                            branch='testbranch', force=True))
 3428         self.expectCommands(
 3429             ExpectShell(workdir='wkdir',
 3430                         command=['git', '--version'])
 3431             + ExpectShell.log('stdio',
 3432                               stdout='git version 1.7.5')
 3433             + 0,
 3434             ExpectShell(workdir='wkdir',
 3435                         command=['git', 'push', url, 'testbranch', '--force'])
 3436             + ExpectShell.log('stdio',
 3437                               stderr="error: failed to push some refs to <url>\n")
 3438             + 1
 3439         )
 3440         self.expectOutcome(result=FAILURE)
 3441         return self.runStep()
 3442 
 3443     def test_push_ssh_key_2_10(self):
 3444         url = 'ssh://github.com/test/test.git'
 3445 
 3446         self.setupStep(
 3447             self.stepClass(workdir='wkdir', repourl=url,
 3448                            branch='testbranch', sshPrivateKey='sshKey'))
 3449 
 3450         ssh_workdir = '/wrk/.wkdir.buildbot'
 3451         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 3452         ssh_command_config = \
 3453             'core.sshCommand=ssh -i "{0}"'.format(ssh_key_path)
 3454 
 3455         self.expectCommands(
 3456             ExpectShell(workdir='wkdir',
 3457                         command=['git', '--version'])
 3458             + ExpectShell.log('stdio',
 3459                               stdout='git version 2.10.0')
 3460             + 0,
 3461             Expect('mkdir', dict(dir=ssh_workdir,
 3462                                  logEnviron=True))
 3463             + 0,
 3464             Expect('downloadFile',
 3465                    dict(blocksize=32768, maxsize=None,
 3466                         reader=ExpectRemoteRef(
 3467                             remotetransfer.StringFileReader),
 3468                         workerdest=ssh_key_path,
 3469                         workdir='wkdir',
 3470                         mode=0o400))
 3471             + 0,
 3472             ExpectShell(workdir='wkdir',
 3473                         command=['git', '-c', ssh_command_config,
 3474                                  'push', url, 'testbranch'])
 3475             + 0,
 3476             Expect('rmdir', dict(dir=ssh_workdir,
 3477                                  logEnviron=True))
 3478             + 0,
 3479         )
 3480         self.expectOutcome(result=SUCCESS)
 3481         return self.runStep()
 3482 
 3483     def test_push_ssh_key_2_3(self):
 3484         url = 'ssh://github.com/test/test.git'
 3485 
 3486         self.setupStep(
 3487             self.stepClass(workdir='wkdir', repourl=url,
 3488                            branch='testbranch', sshPrivateKey='sshKey'))
 3489 
 3490         ssh_workdir = '/wrk/.wkdir.buildbot'
 3491         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 3492         ssh_command = 'ssh -i "{0}"'.format(ssh_key_path)
 3493 
 3494         self.expectCommands(
 3495             ExpectShell(workdir='wkdir',
 3496                         command=['git', '--version'])
 3497             + ExpectShell.log('stdio',
 3498                               stdout='git version 2.3.0')
 3499             + 0,
 3500             Expect('mkdir', dict(dir=ssh_workdir,
 3501                                  logEnviron=True))
 3502             + 0,
 3503             Expect('downloadFile',
 3504                    dict(blocksize=32768, maxsize=None,
 3505                         reader=ExpectRemoteRef(
 3506                             remotetransfer.StringFileReader),
 3507                         workerdest=ssh_key_path,
 3508                         workdir='wkdir',
 3509                         mode=0o400))
 3510             + 0,
 3511             ExpectShell(workdir='wkdir',
 3512                         command=['git', 'push', url, 'testbranch'],
 3513                         env={'GIT_SSH_COMMAND': ssh_command})
 3514             + 0,
 3515             Expect('rmdir', dict(dir=ssh_workdir,
 3516                                  logEnviron=True))
 3517             + 0,
 3518         )
 3519         self.expectOutcome(result=SUCCESS)
 3520         return self.runStep()
 3521 
 3522     def test_push_ssh_key_1_7(self):
 3523         url = 'ssh://github.com/test/test.git'
 3524 
 3525         self.setupStep(
 3526             self.stepClass(workdir='wkdir', repourl=url,
 3527                            branch='testbranch', sshPrivateKey='sshKey'))
 3528 
 3529         ssh_workdir = '/wrk/.wkdir.buildbot'
 3530         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 3531         ssh_wrapper_path = '/wrk/.wkdir.buildbot/ssh-wrapper.sh'
 3532 
 3533         self.expectCommands(
 3534             ExpectShell(workdir='wkdir',
 3535                         command=['git', '--version'])
 3536             + ExpectShell.log('stdio',
 3537                               stdout='git version 1.7.0')
 3538             + 0,
 3539             Expect('mkdir', dict(dir=ssh_workdir,
 3540                                  logEnviron=True))
 3541             + 0,
 3542             Expect('downloadFile',
 3543                    dict(blocksize=32768, maxsize=None,
 3544                         reader=ExpectRemoteRef(
 3545                             remotetransfer.StringFileReader),
 3546                         workerdest=ssh_wrapper_path,
 3547                         workdir='wkdir',
 3548                         mode=0o700))
 3549             + 0,
 3550             Expect('downloadFile',
 3551                    dict(blocksize=32768, maxsize=None,
 3552                         reader=ExpectRemoteRef(
 3553                             remotetransfer.StringFileReader),
 3554                         workerdest=ssh_key_path,
 3555                         workdir='wkdir',
 3556                         mode=0o400))
 3557             + 0,
 3558             ExpectShell(workdir='wkdir',
 3559                         command=['git', 'push', url, 'testbranch'],
 3560                         env={'GIT_SSH': ssh_wrapper_path})
 3561             + 0,
 3562             Expect('rmdir', dict(dir=ssh_workdir,
 3563                                  logEnviron=True))
 3564             + 0,
 3565         )
 3566         self.expectOutcome(result=SUCCESS)
 3567         return self.runStep()
 3568 
 3569     def test_push_ssh_host_key_2_10(self):
 3570         url = 'ssh://github.com/test/test.git'
 3571         self.setupStep(
 3572             self.stepClass(workdir='wkdir', repourl=url,
 3573                            branch='testbranch', sshPrivateKey='sshkey',
 3574                            sshHostKey='sshhostkey'))
 3575 
 3576         ssh_workdir = '/wrk/.wkdir.buildbot'
 3577         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 3578         ssh_known_hosts_path = '/wrk/.wkdir.buildbot/ssh-known-hosts'
 3579         ssh_command_config = \
 3580             'core.sshCommand=ssh -i "{0}" ' \
 3581             '-o "UserKnownHostsFile={1}"'.format(ssh_key_path,
 3582                                                  ssh_known_hosts_path)
 3583 
 3584         self.expectCommands(
 3585             ExpectShell(workdir='wkdir',
 3586                         command=['git', '--version'])
 3587             + ExpectShell.log('stdio',
 3588                               stdout='git version 2.10.0')
 3589             + 0,
 3590             Expect('mkdir', dict(dir=ssh_workdir,
 3591                                  logEnviron=True))
 3592             + 0,
 3593             Expect('downloadFile',
 3594                    dict(blocksize=32768, maxsize=None,
 3595                         reader=ExpectRemoteRef(
 3596                             remotetransfer.StringFileReader),
 3597                         workerdest=ssh_key_path,
 3598                         workdir='wkdir',
 3599                         mode=0o400))
 3600             + 0,
 3601             Expect('downloadFile',
 3602                    dict(blocksize=32768, maxsize=None,
 3603                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
 3604                         workerdest=ssh_known_hosts_path,
 3605                         workdir='wkdir',
 3606                         mode=0o400))
 3607             + 0,
 3608             ExpectShell(workdir='wkdir',
 3609                         command=['git', '-c', ssh_command_config,
 3610                                  'push', url, 'testbranch'])
 3611             + 0,
 3612             Expect('rmdir', dict(dir=ssh_workdir,
 3613                                  logEnviron=True))
 3614             + 0,
 3615         )
 3616         self.expectOutcome(result=SUCCESS)
 3617         return self.runStep()
 3618 
 3619     def test_push_ssh_host_key_2_3(self):
 3620         url = 'ssh://github.com/test/test.git'
 3621         self.setupStep(
 3622             self.stepClass(workdir='wkdir', repourl=url,
 3623                            branch='testbranch', sshPrivateKey='sshkey',
 3624                            sshHostKey='sshhostkey'))
 3625 
 3626         ssh_workdir = '/wrk/.wkdir.buildbot'
 3627         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 3628         ssh_known_hosts_path = '/wrk/.wkdir.buildbot/ssh-known-hosts'
 3629         ssh_command = \
 3630             'ssh -i "{0}" ' \
 3631             '-o "UserKnownHostsFile={1}"'.format(ssh_key_path,
 3632                                                  ssh_known_hosts_path)
 3633 
 3634         self.expectCommands(
 3635             ExpectShell(workdir='wkdir',
 3636                         command=['git', '--version'])
 3637             + ExpectShell.log('stdio',
 3638                               stdout='git version 2.3.0')
 3639             + 0,
 3640             Expect('mkdir', dict(dir=ssh_workdir,
 3641                                  logEnviron=True))
 3642             + 0,
 3643             Expect('downloadFile',
 3644                    dict(blocksize=32768, maxsize=None,
 3645                         reader=ExpectRemoteRef(
 3646                             remotetransfer.StringFileReader),
 3647                         workerdest=ssh_key_path,
 3648                         workdir='wkdir',
 3649                         mode=0o400))
 3650             + 0,
 3651             Expect('downloadFile',
 3652                    dict(blocksize=32768, maxsize=None,
 3653                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
 3654                         workerdest=ssh_known_hosts_path,
 3655                         workdir='wkdir',
 3656                         mode=0o400))
 3657             + 0,
 3658             ExpectShell(workdir='wkdir',
 3659                         command=['git', 'push', url, 'testbranch'],
 3660                         env={'GIT_SSH_COMMAND': ssh_command})
 3661             + 0,
 3662             Expect('rmdir', dict(dir=ssh_workdir,
 3663                                  logEnviron=True))
 3664             + 0,
 3665         )
 3666         self.expectOutcome(result=SUCCESS)
 3667         return self.runStep()
 3668 
 3669     def test_push_ssh_host_key_1_7(self):
 3670         url = 'ssh://github.com/test/test.git'
 3671         self.setupStep(
 3672             self.stepClass(workdir='wkdir', repourl=url,
 3673                            branch='testbranch', sshPrivateKey='sshkey',
 3674                            sshHostKey='sshhostkey'))
 3675 
 3676         ssh_workdir = '/wrk/.wkdir.buildbot'
 3677         ssh_key_path = '/wrk/.wkdir.buildbot/ssh-key'
 3678         ssh_wrapper_path = '/wrk/.wkdir.buildbot/ssh-wrapper.sh'
 3679         ssh_known_hosts_path = '/wrk/.wkdir.buildbot/ssh-known-hosts'
 3680 
 3681         self.expectCommands(
 3682             ExpectShell(workdir='wkdir',
 3683                         command=['git', '--version'])
 3684             + ExpectShell.log('stdio',
 3685                               stdout='git version 1.7.0')
 3686             + 0,
 3687             Expect('mkdir', dict(dir=ssh_workdir,
 3688                                  logEnviron=True))
 3689             + 0,
 3690             Expect('downloadFile',
 3691                    dict(blocksize=32768, maxsize=None,
 3692                         reader=ExpectRemoteRef(
 3693                             remotetransfer.StringFileReader),
 3694                         workerdest=ssh_wrapper_path,
 3695                         workdir='wkdir',
 3696                         mode=0o700))
 3697             + 0,
 3698             Expect('downloadFile',
 3699                    dict(blocksize=32768, maxsize=None,
 3700                         reader=ExpectRemoteRef(
 3701                             remotetransfer.StringFileReader),
 3702                         workerdest=ssh_key_path,
 3703                         workdir='wkdir',
 3704                         mode=0o400))
 3705             + 0,
 3706             Expect('downloadFile',
 3707                    dict(blocksize=32768, maxsize=None,
 3708                         reader=ExpectRemoteRef(remotetransfer.StringFileReader),
 3709                         workerdest=ssh_known_hosts_path,
 3710                         workdir='wkdir',
 3711                         mode=0o400))
 3712             + 0,
 3713             ExpectShell(workdir='wkdir',
 3714                         command=['git', 'push', url, 'testbranch'],
 3715                         env={'GIT_SSH': ssh_wrapper_path})
 3716             + 0,
 3717             Expect('rmdir', dict(dir=ssh_workdir,
 3718                                  logEnviron=True))
 3719             + 0,
 3720         )
 3721         self.expectOutcome(result=SUCCESS)
 3722         return self.runStep()
 3723 
 3724     def test_raise_no_git(self):
 3725         @defer.inlineCallbacks
 3726         def _checkFeatureSupport(self):
 3727             yield
 3728             return False
 3729 
 3730         url = 'ssh://github.com/test/test.git'
 3731         step = self.stepClass(workdir='wkdir', repourl=url, branch='testbranch')
 3732         self.patch(self.stepClass, "checkFeatureSupport", _checkFeatureSupport)
 3733         self.setupStep(step)
 3734         self.expectOutcome(result=EXCEPTION)
 3735         self.runStep()
 3736         self.flushLoggedErrors(WorkerTooOldError)
 3737 
 3738     def test_config_fail_no_branch(self):
 3739         with self.assertRaisesConfigError("GitPush: must provide branch"):
 3740             self.stepClass(workdir='wkdir', repourl="url")
 3741 
 3742 
 3743 class TestGitTag(steps.BuildStepMixin, config.ConfigErrorsMixin,
 3744                  TestReactorMixin, unittest.TestCase):
 3745     stepClass = git.GitTag
 3746 
 3747     def setUp(self):
 3748         self.setUpTestReactor()
 3749         return self.setUpBuildStep()
 3750 
 3751     def tearDown(self):
 3752         return self.tearDownBuildStep()
 3753 
 3754     def test_tag_annotated(self):
 3755         messages = ['msg1', 'msg2']
 3756 
 3757         self.setupStep(
 3758             self.stepClass(workdir='wkdir', tagName='myTag', annotated=True, messages=messages))
 3759         self.expectCommands(
 3760             ExpectShell(workdir='wkdir',
 3761                         command=['git', '--version'])
 3762             + ExpectShell.log('stdio',
 3763                               stdout='git version 1.7.5')
 3764             + 0,
 3765             ExpectShell(workdir='wkdir',
 3766                         command=['git', 'tag', '-a', 'myTag', '-m', 'msg1', '-m', 'msg2'])
 3767             + 0,
 3768         )
 3769         self.expectOutcome(result=SUCCESS)
 3770         return self.runStep()
 3771 
 3772     def test_tag_simple(self):
 3773         self.setupStep(
 3774             self.stepClass(workdir='wkdir',
 3775                            tagName='myTag'))
 3776         self.expectCommands(
 3777             ExpectShell(workdir='wkdir',
 3778                         command=['git', '--version'])
 3779             + ExpectShell.log('stdio',
 3780                               stdout='git version 1.7.5')
 3781             + 0,
 3782             ExpectShell(workdir='wkdir',
 3783                         command=['git', 'tag', 'myTag'])
 3784             + 0,
 3785         )
 3786         self.expectOutcome(result=SUCCESS)
 3787         return self.runStep()
 3788 
 3789     def test_tag_force(self):
 3790         self.setupStep(
 3791             self.stepClass(workdir='wkdir',
 3792                            tagName='myTag', force=True))
 3793         self.expectCommands(
 3794             ExpectShell(workdir='wkdir',
 3795                         command=['git', '--version'])
 3796             + ExpectShell.log('stdio',
 3797                               stdout='git version 1.7.5')
 3798             + 0,
 3799             ExpectShell(workdir='wkdir',
 3800                         command=['git', 'tag', 'myTag', '--force'])
 3801             + 0,
 3802         )
 3803         self.expectOutcome(result=SUCCESS)
 3804         return self.runStep()
 3805 
 3806     def test_tag_fail_already_exist(self):
 3807         self.setupStep(
 3808             self.stepClass(workdir='wkdir',
 3809                            tagName='myTag'))
 3810         self.expectCommands(
 3811             ExpectShell(workdir='wkdir',
 3812                         command=['git', '--version'])
 3813             + ExpectShell.log('stdio',
 3814                               stdout='git version 1.7.5')
 3815             + 0,
 3816             ExpectShell(workdir='wkdir',
 3817                         command=['git', 'tag', 'myTag'])
 3818             + ExpectShell.log('stdio',
 3819                               stderr="fatal: tag \'%s\' already exist\n")
 3820             + 1
 3821         )
 3822         self.expectOutcome(result=FAILURE)
 3823         return self.runStep()
 3824 
 3825     def test_config_annotated_no_messages(self):
 3826         with self.assertRaises(bbconfig.ConfigErrors):
 3827             self.setupStep(
 3828                 self.stepClass(workdir='wkdir', tagName='myTag', annotated=True))
 3829 
 3830     def test_config_no_tag_name(self):
 3831         with self.assertRaises(bbconfig.ConfigErrors):
 3832             self.setupStep(
 3833                 self.stepClass(workdir='wkdir'))
 3834 
 3835     def test_config_not_annotated_but_meessages(self):
 3836         with self.assertRaises(bbconfig.ConfigErrors):
 3837             self.setupStep(
 3838                 self.stepClass(workdir='wkdir', tagName='myTag', messages=['msg']))
 3839 
 3840     def test_config_annotated_message_not_list(self):
 3841         with self.assertRaises(bbconfig.ConfigErrors):
 3842             self.setupStep(
 3843                 self.stepClass(workdir='wkdir', tagName='myTag', annotated=True, messages="msg"))
 3844 
 3845     def test_raise_no_git(self):
 3846         @defer.inlineCallbacks
 3847         def _checkFeatureSupport(self):
 3848             yield
 3849             return False
 3850 
 3851         step = self.stepClass(workdir='wdir', tagName='myTag')
 3852         self.patch(self.stepClass, "checkFeatureSupport", _checkFeatureSupport)
 3853         self.setupStep(step)
 3854         self.expectOutcome(result=EXCEPTION)
 3855         self.runStep()
 3856         self.flushLoggedErrors(WorkerTooOldError)
 3857 
 3858 
 3859 class TestGitCommit(steps.BuildStepMixin, config.ConfigErrorsMixin,
 3860                     TestReactorMixin,
 3861                     unittest.TestCase):
 3862     stepClass = git.GitCommit
 3863 
 3864     def setUp(self):
 3865         self.setUpTestReactor()
 3866         self.message_list = ['my commit', '42']
 3867         self.path_list = ['file1.txt', 'file2.txt']
 3868 
 3869         return self.setUpBuildStep()
 3870 
 3871     def tearDown(self):
 3872         return self.tearDownBuildStep()
 3873 
 3874     def test_add_fail(self):
 3875         self.setupStep(
 3876             self.stepClass(workdir='wkdir', paths=self.path_list, messages=self.message_list))
 3877         self.expectCommands(
 3878             ExpectShell(workdir='wkdir',
 3879                         command=['git', '--version'])
 3880             + ExpectShell.log('stdio',
 3881                               stdout='git version 1.7.5')
 3882             + 0,
 3883             ExpectShell(workdir='wkdir',
 3884                         command=['git', 'symbolic-ref', 'HEAD'])
 3885             + ExpectShell.log('stdio',
 3886                               stdout='refs/head/myBranch')
 3887             + 0,
 3888             ExpectShell(workdir='wkdir',
 3889                         command=['git', 'add', 'file1.txt', 'file2.txt'])
 3890             + 1,
 3891         )
 3892         self.expectOutcome(result=FAILURE)
 3893         return self.runStep()
 3894 
 3895     def test_commit(self):
 3896         self.setupStep(
 3897             self.stepClass(workdir='wkdir', paths=self.path_list, messages=self.message_list))
 3898         self.expectCommands(
 3899             ExpectShell(workdir='wkdir',
 3900                         command=['git', '--version'])
 3901             + ExpectShell.log('stdio',
 3902                               stdout='git version 1.7.5')
 3903             + 0,
 3904             ExpectShell(workdir='wkdir',
 3905                         command=['git', 'symbolic-ref', 'HEAD'])
 3906             + ExpectShell.log('stdio',
 3907                               stdout='refs/head/myBranch')
 3908             + 0,
 3909             ExpectShell(workdir='wkdir',
 3910                         command=['git', 'add', 'file1.txt', 'file2.txt'])
 3911             + 0,
 3912             ExpectShell(workdir='wkdir',
 3913                         command=['git', 'commit', '-m', 'my commit', '-m', '42'])
 3914             + 0,
 3915         )
 3916         self.expectOutcome(result=SUCCESS)
 3917         return self.runStep()
 3918 
 3919     def test_detached_head(self):
 3920         self.setupStep(
 3921             self.stepClass(workdir='wkdir', paths=self.path_list, messages=self.message_list))
 3922         self.expectCommands(
 3923             ExpectShell(workdir='wkdir',
 3924                         command=['git', '--version'])
 3925             + ExpectShell.log('stdio',
 3926                               stdout='git version 1.7.5')
 3927             + 0,
 3928             ExpectShell(workdir='wkdir',
 3929                         command=['git', 'symbolic-ref', 'HEAD'])
 3930             + ExpectShell.log('stdio',
 3931                               stdout='')
 3932             + 1,
 3933         )
 3934         self.expectOutcome(result=FAILURE)
 3935         return self.runStep()
 3936 
 3937     def test_config_no_files_arg(self):
 3938         with self.assertRaisesConfigError(
 3939                 "GitCommit: must provide paths"):
 3940             self.stepClass(workdir='wkdir', messages=self.message_list)
 3941 
 3942     def test_config_files_not_a_list(self):
 3943         with self.assertRaisesConfigError(
 3944                 "GitCommit: paths must be a list"):
 3945             self.stepClass(workdir='wkdir', paths="test.txt", messages=self.message_list)
 3946 
 3947     def test_config_no_messages_arg(self):
 3948         with self.assertRaisesConfigError(
 3949                 "GitCommit: must provide messages"):
 3950             self.stepClass(workdir='wkdir', paths=self.path_list)
 3951 
 3952     def test_config_messages_not_a_list(self):
 3953         with self.assertRaisesConfigError(
 3954                 "GitCommit: messages must be a list"):
 3955             self.stepClass(workdir='wkdir', paths=self.path_list, messages="my message")
 3956 
 3957     def test_raise_no_git(self):
 3958         @defer.inlineCallbacks
 3959         def _checkFeatureSupport(self):
 3960             yield
 3961             return False
 3962 
 3963         step = self.stepClass(workdir='wkdir', paths=self.path_list, messages=self.message_list)
 3964         self.patch(self.stepClass, "checkFeatureSupport", _checkFeatureSupport)
 3965         self.setupStep(step)
 3966         self.expectOutcome(result=EXCEPTION)
 3967         self.runStep()
 3968         self.flushLoggedErrors(WorkerTooOldError)