Beispiel #1
0
 def update_batou(self):
     """Update the version pins on batou as well"""
     deployment_repo = self.buildout.sources.get('deployment')
     if deployment_repo is None:
         logger.info('No deployment repository sources found!'
                     '\n'
                     'Batou can not be updated!')
         return
     # clone the repo
     with git_repo(deployment_repo, shallow=False) as repo:
         # get components/plone/versions/versions.cfg Buildout
         path = 'components/plone/versions/versions.cfg'
         plone_versions = '{0}/{1}'.format(repo.working_tree_dir, path)
         deployment_buildout = Buildout(
             sources_file=plone_versions,
             checkouts_file=plone_versions,
             versions_file=plone_versions)
         # update version pins
         for dist_name in self.versions:
             deployment_buildout.set_version(dist_name,
                                             self.versions[dist_name])
         # commit and push the repo
         repo.index.add([
             path,
         ])
         repo.index.commit(message=self.commit_message.encode('utf-8'))
         # push the changes
         repo.remote().push()
    def test_git_repo_context_manager_shallow(self):
        """Check that the context manager returns a shallow clone"""
        # make some commits
        for i in range(1, 5):
            self._commit(self.user_repo, msg='Commit {0}'.format(i))
        self.user_repo.remote().push()

        # use the context manager to check that only some commits are fetched
        with git_repo(self.source, depth=2) as repo:
            commits = [
                c
                for c in repo.iter_commits()
            ]
            self.assertEqual(
                len(commits),
                2
            )