diff --git a/repo2docker/app.py b/repo2docker/app.py index 7820f0b4..562fa1cf 100644 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -176,9 +176,9 @@ class Repo2Docker(Application): sys.exit(1) if ref: - if len(ref.split('/')) != 2: - raise ValueError('Expected --ref to be of the form ' - 'remote/reference, but got %s' % ref) + if self.repo_type == "remote" and len(ref.split('/')) < 2: + # Ensure that the ref has `origin` in front + ref = '/'.join(["origin", ref]) try: for line in execute_cmd(['git', 'reset', '--hard', ref], cwd=checkout_path, @@ -248,8 +248,8 @@ class Repo2Docker(Application): argparser.add_argument( '--ref', - help=('If building a git url, which reference to check out. Must ' - 'be of the form `remote/reference`. E.g., `origin/master`.') + help=('If building a git url, which reference to check out. ' + 'E.g., `master`.') ) argparser.add_argument( diff --git a/tests/argumentvalidation.py b/tests/argumentvalidation.py index e1a73e9c..f38c056c 100644 --- a/tests/argumentvalidation.py +++ b/tests/argumentvalidation.py @@ -230,13 +230,3 @@ def test_docker_no_build_success(): builddir = os.path.dirname(__file__) + '/../' assert validate_arguments(builddir, args_list, "", True) - - -def test_ref_has_correct_form(): - """ - Test to check if --ref is given with the form `remote/reference` - """ - builddir = os.path.dirname(__file__) - args_list = ['--no-run', '--no-build', '--ref', 'myreference'] - - assert not validate_arguments(builddir, args_list, 'Expected --ref to be of the form remote/reference, but got myreference') diff --git a/tests/external/reproductions.repos.yaml b/tests/external/reproductions.repos.yaml index e69b6068..defba917 100644 --- a/tests/external/reproductions.repos.yaml +++ b/tests/external/reproductions.repos.yaml @@ -3,3 +3,8 @@ url: https://github.com/minrk/ligo-binder/ ref: origin/b8259dac9eb verify: python -c 'import matplotlib' +# To test that ref is added if not present +- name: LIGO Gravitational Waves + url: https://github.com/minrk/ligo-binder/ + ref: b8259dac9eb + verify: python -c 'import matplotlib'