

def archive(self, ref, destination, *archive_args):
    '\n        Archive the specified GIT ref to the specified destination\n\n        Any extra args are passed to the sh command directly so you can\n        add extra flags for `git archive` should you desire.\n        '
    tmp_dir = tempfile.mkdtemp()
    tar_file = None
    try:
        git = sh.git.bake(_cwd=tmp_dir, _env={
            'GIT_SSH': 'loose_ssh.sh',
        })
        self.log.debug(('Cloning %s to %s' % (self.url, tmp_dir)))
        git('clone', '--recursive', self.url, tmp_dir)
        self.log.debug("Archiving '{ref}' to {destination}".format(ref=ref, destination=destination))
        settings.mkdir_p(destination)
        (fd, tar_file) = tempfile.mkstemp()
        git.archive(('origin/%s' % ref), *archive_args, _out=tar_file)
        sh.tar('xpf', tar_file, _cwd=destination)
    finally:
        if tar_file:
            os.remove(tar_file)
        if os.path.isdir(tmp_dir):
            shutil.rmtree(tmp_dir)

dataset/ETHPy150Open stackstrap/stackstrap/stackstrap/repository.py Repository.archive/original