diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-10-22 09:12:45 +0000 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-10-22 09:29:55 +0000 |
commit | e47dcede79e5b7e5dccee485826e5dd97e53a5da (patch) | |
tree | 62c4476907b5b92d2c989f4dc27ead7fe4799a43 | |
parent | 6655ef761d77c3234c3cf775bf5ee38bd3f43b0c (diff) | |
download | morph-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.py | 6 |
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) |