Skip to content

Commit 1ebb4b5

Browse files
committed
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.
1 parent 19c698e commit 1ebb4b5

File tree

1 file changed

+11
-2
lines changed
  • repo2docker/contentproviders

1 file changed

+11
-2
lines changed

repo2docker/contentproviders/git.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,18 @@ def fetch(self, spec, output_dir, yield_output=False):
4747
self.log.error(
4848
"Failed to check out ref %s", ref, extra=dict(phase="failed")
4949
)
50-
raise ValueError("Failed to check out ref {}".format(ref))
50+
if ref == "master":
51+
msg = (
52+
"Failed to check out the 'master' branch. "
53+
"Maybe the default branch is not named 'master' "
54+
"for this repository.\n\nTry not explicitly "
55+
"specifying `--ref`."
56+
)
57+
else:
58+
msg = "Failed to check out ref {}".format(ref)
59+
raise ValueError(msg)
5160
# We don't need to explicitly checkout things as the reset will
52-
# take of that. If the hash is resolved above, we should be
61+
# take care of that. If the hash is resolved above, we should be
5362
# able to reset to it
5463
for line in execute_cmd(
5564
["git", "reset", "--hard", hash], cwd=output_dir, capture=yield_output

0 commit comments

Comments
 (0)