def archive(self, ref, destination, *archive_args):
        """
        Archive the specified GIT ref to the specified destination

        Any extra args are passed to the sh command directly so you can
        add extra flags for `git archive` should you desire.
        """
        tmp_dir = tempfile.mkdtemp()
        tar_file = None

        try:
            # create our git interface via the sh module
            # see:
            # github.com/stackstrap/stackstrap/blob/master/scripts/loose_ssh.sh
            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