示例#1
0
    def install(self, project, renderer):
        dest_path = self.get_installation_path(project, renderer)
        if os.path.exists(dest_path):
            if system.path_is_symlink(dest_path):
                system.remove_file(dest_path)
            else:
                system.rmdir(dest_path)

        system.move(self._checkout(), dest_path)
示例#2
0
文件: git.py 项目: massmutual/dbt
def clone(repo, cwd, dirname=None, remove_git_dir=False):
    clone_cmd = ['git', 'clone', '--depth', '1', repo]

    if dirname is not None:
        clone_cmd.append(dirname)

    result = run_cmd(cwd, clone_cmd)

    if remove_git_dir:
        rmdir(os.path.join(dirname, '.git'))

    return result
示例#3
0
def clone(repo, cwd, dirname=None, remove_git_dir=False):
    clone_cmd = ['git', 'clone', '--depth', '1', repo]

    if dirname is not None:
        clone_cmd.append(dirname)

    result = run_cmd(cwd, clone_cmd, env={'LC_ALL': 'C'})

    if remove_git_dir:
        rmdir(os.path.join(dirname, '.git'))

    return result
示例#4
0
def clone(repo, cwd, dirname=None, remove_git_dir=False, branch=None):
    clone_cmd = ['git', 'clone', '--depth', '1']

    if branch is not None:
        clone_cmd.extend(['--branch', branch])

    clone_cmd.append(repo)

    if dirname is not None:
        clone_cmd.append(dirname)

    result = run_cmd(cwd, clone_cmd, env={'LC_ALL': 'C'})

    if remove_git_dir:
        rmdir(os.path.join(dirname, '.git'))

    return result
示例#5
0
def clone(repo,
          cwd,
          dirname=None,
          remove_git_dir=False,
          revision=None,
          subdirectory=None):
    has_revision = revision is not None
    is_commit = _is_commit(revision or "")

    clone_cmd = ['git', 'clone', '--depth', '1']
    if subdirectory:
        logger.debug(
            '  Subdirectory specified: {}, using sparse checkout.'.format(
                subdirectory))
        out, _ = run_cmd(cwd, ['git', '--version'], env={'LC_ALL': 'C'})
        git_version = version.parse(
            re.search(r"\d+\.\d+\.\d+", out.decode("utf-8")).group(0))
        if not git_version >= version.parse("2.25.0"):
            # 2.25.0 introduces --sparse
            raise RuntimeError(
                "Please update your git version to pull a dbt package "
                "from a subdirectory: your version is {}, >= 2.25.0 needed".
                format(git_version))
        clone_cmd.extend(['--filter=blob:none', '--sparse'])

    if has_revision and not is_commit:
        clone_cmd.extend(['--branch', revision])

    clone_cmd.append(repo)

    if dirname is not None:
        clone_cmd.append(dirname)
    result = run_cmd(cwd, clone_cmd, env={'LC_ALL': 'C'})

    if subdirectory:
        run_cmd(os.path.join(cwd, dirname or ''),
                ['git', 'sparse-checkout', 'set', subdirectory])

    if remove_git_dir:
        rmdir(os.path.join(dirname, '.git'))

    return result
示例#6
0
    def install(self, project):
        src_path = self.resolve_path(project)
        dest_path = self.get_installation_path(project)

        can_create_symlink = system.supports_symlinks()

        if system.path_exists(dest_path):
            if not system.path_is_symlink(dest_path):
                system.rmdir(dest_path)
            else:
                system.remove_file(dest_path)

        if can_create_symlink:
            logger.debug('  Creating symlink to local dependency.')
            system.make_symlink(src_path, dest_path)

        else:
            logger.debug('  Symlinks are not available on this '
                         'OS, copying dependency.')
            shutil.copytree(src_path, dest_path)