示例#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
示例#2
0
 def test_correct(self):
     for (url, expected_name) in [
         ('example.com:test.git', 'test.git'),
         ('example.com:test', 'test.git'),
         ('[email protected]:test.git', 'test.git'),
         ('[email protected]:test', 'test.git'),
         ('example.com:prefix/test.git', 'test.git'),
         ('example.com:prefix/test', 'test.git'),
         ('example.com:test-with-hyphen', 'test-with-hyphen.git'),
         ('example.com:some-prefix/test-with-hyphen', 'test-with-hyphen.git'),
     ]:
         assert GitVcs.get_repository_name(url) == expected_name
示例#3
0
 def test_correct(self):
     for (url, expected_name) in [
         ('example.com:test.git', 'test.git'),
         ('example.com:test', 'test.git'),
         ('[email protected]:test.git', 'test.git'),
         ('[email protected]:test', 'test.git'),
         ('example.com:prefix/test.git', 'test.git'),
         ('example.com:prefix/test', 'test.git'),
         ('example.com:test-with-hyphen', 'test-with-hyphen.git'),
         ('example.com:some-prefix/test-with-hyphen',
          'test-with-hyphen.git'),
     ]:
         assert GitVcs.get_repository_name(url) == expected_name
示例#4
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
示例#5
0
from changes.config import db
from changes.constants import Result, Status
from changes.db.utils import try_create
from changes.lib import build_context_lib
from changes.lib.coverage import get_coverage_by_build_id, merged_coverage_data
from changes.models import Build, ItemOption, ProjectOption, RepositoryBackend, Source
from changes.models.event import Event, EventType
from changes.utils.http import build_uri
from changes.utils.phabricator_utils import logger, PhabricatorClient, post_comment
from changes.vcs.git import GitVcs
from changes.vcs.hg import MercurialVcs
from sqlalchemy.orm import joinedload

# Copied from api/serializer/models/repository.py
DEFAULT_BRANCHES = {
    RepositoryBackend.git: GitVcs.get_default_revision(),
    RepositoryBackend.hg: MercurialVcs.get_default_revision(),
    RepositoryBackend.unknown: ''
}


def get_options(project_id):
    return dict(
        db.session.query(ProjectOption.name, ProjectOption.value).filter(
            ProjectOption.project_id == project_id,
            ProjectOption.name.in_([
                'phabricator.notify',
                'phabricator.coverage',
            ])))

示例#6
0
 def get_vcs(self):
     return GitVcs(url=self.url, path=self.path)
from changes.config import db
from changes.constants import Result, Status
from changes.db.utils import try_create
from changes.lib import build_context_lib
from changes.lib.coverage import get_coverage_by_build_id, merged_coverage_data
from changes.models import Build, ItemOption, ProjectOption, RepositoryBackend, Source
from changes.models.event import Event, EventType
from changes.utils.http import build_uri
from changes.utils.phabricator_utils import logger, PhabricatorClient, post_comment
from changes.vcs.git import GitVcs
from changes.vcs.hg import MercurialVcs
from sqlalchemy.orm import joinedload

# Copied from api/serializer/models/repository.py
DEFAULT_BRANCHES = {
    RepositoryBackend.git: GitVcs.get_default_revision(),
    RepositoryBackend.hg: MercurialVcs.get_default_revision(),
    RepositoryBackend.unknown: ''
}


def get_options(project_id):
    return dict(
        db.session.query(
            ProjectOption.name, ProjectOption.value
        ).filter(
            ProjectOption.project_id == project_id,
            ProjectOption.name.in_([
                'phabricator.notify',
                'phabricator.coverage',
            ])