def setUp(self): with mock.patch('bigitr.log.Log') as mocklog: appConfig = StringIO('[global]\n' 'logdir = /logs\n' 'gitdir = /git\n' '[import]\n' 'cvsdir = /cvs\n' '\n') repConfig = StringIO('[repo]\n' 'gitroot = git@host\n' 'cvspath = sub/module\n' 'prehook.git = precommand arg\n' 'posthook.git = postcommand arg\n' 'prehook.git.brnch = precommand brnch\n' 'posthook.git.brnch = postcommand brnch\n' 'prehook.imp.git = preimpcommand arg\n' 'posthook.imp.git = postimpcommand arg\n' 'prehook.imp.git.brnch = preimpcommand brnch\n' 'posthook.imp.git.brnch = postimpcommand brnch\n' 'prehook.exp.git = preexpcommand arg\n' 'posthook.exp.git = postexpcommand arg\n' 'prehook.exp.git.brnch = preexpcommand brnch\n' 'posthook.exp.git.brnch = postexpcommand brnch\n' '\n') self.ctx = context.Context(appConfig, repConfig) self.git = git.Git(self.ctx, 'repo') self.mocklog = mocklog()
def test_synchronize(self): Git = git.Git(self.ctx, 'repo') self.sync.synchronize('repo', Git) self.sync.imp.importBranches.assert_has_calls( [mock.call('repo', Git), mock.call('repo', Git)]) self.sync.exp.exportBranches.assert_called_once_with('repo', Git)
def test_synchronizeNoPreImport(self): Git = git.Git(self.ctx, 'repo') self.ctx.getExportPreImport = mock.Mock() self.ctx.getExportPreImport.return_value = False self.sync.synchronize('repo', Git) self.ctx.getExportPreImport.assert_called_once_with() self.sync.imp.importBranches.assert_called_once_with('repo', Git) self.sync.exp.exportBranches.assert_called_once_with('repo', Git)
def synchronizeAll(self): for repository in self.ctx.getRepositories(): Git = git.Git(self.ctx, repository) try: self.synchronize(repository, Git) except shell.ErrorExitCode, e: # report errors from commands that fail Git.log.mailLastOutput(str(e)) self.err.report(repository) except:
def process(self): for repository, branch in self.getBranchMaps(): Git = git.Git(self.ctx, repository) try: if not branch: # empty branch is unspecified branch = None self.do(repository, Git, requestedBranch=branch) except shell.ErrorExitCode, e: # report errors from commands that fail Git.log.mailLastOutput(str(e)) self.runner.err.report(repository) except:
def exportAll(self): for repository in self.ctx.getRepositories(): Git = git.Git(self.ctx, repository) self.exportBranches(repository, Git)