From e47dcede79e5b7e5dccee485826e5dd97e53a5da Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Thu, 22 Oct 2015 09:12:45 +0000 Subject: 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 --- morphlib/plugins/get_repo_plugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1