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
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
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', ]))) def get_repo_options(repo_id):
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', ]) )
def get_vcs(self): return MercurialVcs(url=self.url, path=self.path)