summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2015-10-22 09:12:45 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2015-10-22 09:29:55 +0000
commite47dcede79e5b7e5dccee485826e5dd97e53a5da (patch)
tree62c4476907b5b92d2c989f4dc27ead7fe4799a43
parent6655ef761d77c3234c3cf775bf5ee38bd3f43b0c (diff)
downloadmorph-e47dcede79e5b7e5dccee485826e5dd97e53a5da.tar.gz
Improve get-repo error message
When attempting to get a repo with no commit at the ref we want, we get a 'No such file or directory' error, which is confusing, this is because we attempt to remove the directory we plan to clone into, but if there's no commit at the ref we want then we don't get as far as running git clone, so the directory doesn't exist, and we fail to remove it. This commit improves the error message by catching the InvalidRefError separately. Change-Id: Ibca20dd995d858713e56ab834daa97a8297cafc8
-rw-r--r--morphlib/plugins/get_repo_plugin.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/morphlib/plugins/get_repo_plugin.py b/morphlib/plugins/get_repo_plugin.py
index 9c1c19f1..c1cb6d0e 100644
--- a/morphlib/plugins/get_repo_plugin.py
+++ b/morphlib/plugins/get_repo_plugin.py
@@ -107,7 +107,11 @@ class GetRepoPlugin(cliapp.Plugin):
try:
self._clone_repo(cached_repo, dirname,
- ref or chunk_spec['ref'])
+ ref or chunk_spec['ref'])
+ except morphlib.gitdir.InvalidRefError:
+ raise cliapp.AppException(
+ "Cannot get '%s', repo has no commit at ref %s."
+ % (chunk_spec['name'], ref or chunk_spec['ref']))
except BaseException as e:
logging.debug('Removing %s due to %s', dirname, e)
shutil.rmtree(dirname)