def _checkout(self): """Performs a shallow clone of the repository into the downloads directory. This function can be called repeatedly. If the project has already been checked out at this version, it will be a no-op. Returns the path to the checked out directory.""" try: dir_ = git.clone_and_checkout(self.git, get_downloads_path(), branch=self.revision, dirname=self._checkout_name) except ExecutableError as exc: if exc.cmd and exc.cmd[0] == 'git': logger.error( 'Make sure git is installed on your machine. More ' 'information: ' 'https://docs.getdbt.com/docs/package-management') raise return os.path.join(get_downloads_path(), dir_)
def install(self, project, renderer): metadata = self.fetch_metadata(project, renderer) tar_name = '{}.{}.tar.gz'.format(self.package, self.version) tar_path = os.path.realpath( os.path.join(get_downloads_path(), tar_name)) system.make_directory(os.path.dirname(tar_path)) download_url = metadata.downloads.tarball system.download(download_url, tar_path) deps_path = project.modules_path package_name = self.get_project_name(project, renderer) system.untar_package(tar_path, deps_path, package_name)