Merge pull request #131 from jupyter/revert-120-max-clone-depth

Revert "[MRG] Add limit on git clone depth"
pull/132/head
Chris Holdgraf 2017-11-01 16:28:20 -07:00 zatwierdzone przez GitHub
commit 3459b7705c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 14 dodań i 65 usunięć

Wyświetl plik

@ -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(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', 'clone', url, 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))
self.log.error('Failed to clone repository!', extra=dict(phase='failed'))
sys.exit(1)
# create a shallow clone first
_clone(depth=50)
if not _contains(ref):
# have to create a full clone
_unshallow()
_checkout(ref)
if ref:
try:
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'))
sys.exit(1)
def get_argparser(self):
argparser = argparse.ArgumentParser()

Wyświetl plik

@ -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 && \

Wyświetl plik

@ -5,3 +5,4 @@ import sys
assert sys.version_info[:2] == (3, 5), sys.version
import jupyter
import jupyterhub

Wyświetl plik

@ -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" ]'