From 1ebb4b5d87ec819c156e4b351ea03e7bd0b5dcae Mon Sep 17 00:00:00 2001 From: Tim Head Date: Thu, 22 Oct 2020 08:04:29 +0200 Subject: [PATCH] Add explicit error message when `master` is specified Provide a specific error messaeg with a hint towards solution when a user specifies `master` as ref and we can't find it. --- repo2docker/contentproviders/git.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/repo2docker/contentproviders/git.py b/repo2docker/contentproviders/git.py index e203fa6b..5c914860 100644 --- a/repo2docker/contentproviders/git.py +++ b/repo2docker/contentproviders/git.py @@ -47,9 +47,18 @@ class Git(ContentProvider): self.log.error( "Failed to check out ref %s", ref, extra=dict(phase="failed") ) - raise ValueError("Failed to check out ref {}".format(ref)) + if ref == "master": + msg = ( + "Failed to check out the 'master' branch. " + "Maybe the default branch is not named 'master' " + "for this repository.\n\nTry not explicitly " + "specifying `--ref`." + ) + else: + msg = "Failed to check out ref {}".format(ref) + raise ValueError(msg) # We don't need to explicitly checkout things as the reset will - # take of that. If the hash is resolved above, we should be + # take care of that. If the hash is resolved above, we should be # able to reset to it for line in execute_cmd( ["git", "reset", "--hard", hash], cwd=output_dir, capture=yield_output