Beispiel #1
0
    def get_vcs(self):
        from changes.models.option import ItemOption
        from changes.vcs.git import GitVcs
        from changes.vcs.hg import MercurialVcs

        options = dict(
            db.session.query(ItemOption.name, ItemOption.value).filter(
                ItemOption.item_id == self.id,
                ItemOption.name.in_([
                    'auth.username',
                ])))

        kwargs = {
            'path':
            os.path.join(os.path.expanduser(current_app.config['REPO_ROOT']),
                         self.id.hex),
            'url':
            self.url,
            'username':
            options.get('auth.username'),
        }

        if self.backend == RepositoryBackend.git:
            return GitVcs(**kwargs)
        elif self.backend == RepositoryBackend.hg:
            return MercurialVcs(**kwargs)
        else:
            return None
Beispiel #2
0
def get_vcs(repository):
    """ Gets the Vcs based on repository options. Based on repository.get_vcs()
    """
    kwargs = {
        'path': os.getcwd(),
        'url': repository.url,
        'username': getpass.getuser(),
    }
    from changes.vcs.git import GitVcs
    from changes.vcs.hg import MercurialVcs

    if repository.backend == RepositoryBackend.git:
        return GitVcs(**kwargs)
    elif repository.backend == RepositoryBackend.hg:
        return MercurialVcs(**kwargs)
    else:
        return None
Beispiel #3
0
 def get_vcs(self):
     return MercurialVcs(url=self.url, path=self.path)