From a7b1519b4dfbc112fa064497715e51e23ee4a34a Mon Sep 17 00:00:00 2001 From: Yuvi Panda Date: Wed, 1 Nov 2017 16:27:26 -0700 Subject: [PATCH] Revert "[MRG] Add limit on git clone depth" --- repo2docker/app.py | 63 +++++-------------------- repo2docker/detectors.py | 2 + tests/dockerfile/legacy/verify | 1 + tests/external/shallow-clone.repos.yaml | 13 ----- 4 files changed, 14 insertions(+), 65 deletions(-) delete mode 100644 tests/external/shallow-clone.repos.yaml diff --git a/repo2docker/app.py b/repo2docker/app.py index a985fa38..8cd8367e 100644 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -91,63 +91,22 @@ class Repo2Docker(Application): ) def fetch(self, url, ref, checkout_path): - def _clone(depth=None): - if depth is not None: - command = ['git', 'clone', '--depth', str(depth), - url, checkout_path] - else: - command = ['git', 'clone', url, checkout_path] + try: + for line in execute_cmd(['git', 'clone', url, checkout_path], + capture=self.json_logs): + self.log.info(line, extra=dict(phase='fetching')) + except subprocess.CalledProcessError: + self.log.error('Failed to clone repository!', extra=dict(phase='failed')) + sys.exit(1) + if ref: try: - for line in execute_cmd(command, capture=self.json_logs): - self.log.info(line, extra=dict(phase='fetching')) - except subprocess.CalledProcessError: - self.log.error('Failed to clone repository!', - extra=dict(phase='failed')) - raise RuntimeError("Failed to clone %s." % url) - - def _unshallow(): - try: - for line in execute_cmd(['git', 'fetch', '--unshallow'], - capture=self.json_logs, - cwd=checkout_path): - self.log.info(line, extra=dict(phase='fetching')) - except subprocess.CalledProcessError: - self.log.error('Failed to unshallow repository!', - extra=dict(phase='failed')) - raise RuntimeError("Failed to create a full clone of" - " %s." % url) - - def _contains(ref): - try: - for line in execute_cmd(['git', 'cat-file', '-t', ref], - capture=self.json_logs, - cwd=checkout_path): - self.log.debug(line, extra=dict(phase='fetching')) - except subprocess.CalledProcessError: - return False - - return True - - def _checkout(ref): - try: - for line in execute_cmd(['git', 'reset', '--hard', ref], - cwd=checkout_path, + for line in execute_cmd(['git', 'reset', '--hard', ref], cwd=checkout_path, capture=self.json_logs): self.log.info(line, extra=dict(phase='fetching')) except subprocess.CalledProcessError: - self.log.error('Failed to check out ref %s', ref, - extra=dict(phase='failed')) - raise RuntimeError("Failed to checkout reference %s for" - " %s." % (ref, url)) - - # create a shallow clone first - _clone(depth=50) - - if not _contains(ref): - # have to create a full clone - _unshallow() - _checkout(ref) + self.log.error('Failed to check out ref %s', ref, extra=dict(phase='failed')) + sys.exit(1) def get_argparser(self): argparser = argparse.ArgumentParser() diff --git a/repo2docker/detectors.py b/repo2docker/detectors.py index 72a7879a..470aa601 100644 --- a/repo2docker/detectors.py +++ b/repo2docker/detectors.py @@ -733,7 +733,9 @@ class LegacyBinderDockerBuildPack(DockerBuildPack): USER main WORKDIR /home/main/notebooks ENV PATH /home/main/anaconda2/envs/python3/bin:$PATH + ARG JUPYTERHUB_VERSION RUN conda install -yq -n python3 notebook==5.0.0 ipykernel==4.6.0 && \ + pip install --no-cache-dir jupyterhub==${JUPYTERHUB_VERSION} && \ conda remove -yq -n python3 nb_conda_kernels && \ conda install -yq -n root ipykernel==4.6.0 && \ /home/main/anaconda2/envs/python3/bin/ipython kernel install --sys-prefix && \ diff --git a/tests/dockerfile/legacy/verify b/tests/dockerfile/legacy/verify index 5fd1485c..e7d0b09d 100755 --- a/tests/dockerfile/legacy/verify +++ b/tests/dockerfile/legacy/verify @@ -5,3 +5,4 @@ import sys assert sys.version_info[:2] == (3, 5), sys.version import jupyter +import jupyterhub diff --git a/tests/external/shallow-clone.repos.yaml b/tests/external/shallow-clone.repos.yaml deleted file mode 100644 index cdeccf9c..00000000 --- a/tests/external/shallow-clone.repos.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Check that we correctly detect that this ref is more than 50 commits ago -# and trigger a full clone of the repository -- name: A dummy repo with 100 commits - unshallow to reach ref - url: https://github.com/betatim/repo2docker-ci-clone-depth - ref: f702ae5c612ca0dcaf77954f9f5dd4ede7cb9b5f - verify: python -c "commit = open('COMMIT').read(); assert int(commit) == 1, 'this is not the first commit'" - -- name: A dummy repo with 100 commits - shallow clone is enough - url: https://github.com/betatim/repo2docker-ci-clone-depth - ref: 28674ab4da34585525d9c5451f6d6a872522d017 - # we checkout the second to last commit, hence the log has 49 entries at a - # max clone depth of 50 - verify: /bin/bash -c '[ $(git log --oneline | wc -l) == "49" ]'