diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-12-03 12:10:21 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-12-04 15:47:00 +0000 |
commit | b9af32ba9f60b66ef1487438f97a37c54bf95b3b (patch) | |
tree | d2f17a4258a3af5a6dee2ee4edc5a367103c5cc2 | |
parent | e7110f6551d25ac290f48abaa3a58262a98ba6e3 (diff) | |
download | morph-b9af32ba9f60b66ef1487438f97a37c54bf95b3b.tar.gz |
Give a better error when no repos are found in a system branch
Previously, if no repos were found Morph would raise 'ValueError: need
more than 0 values to unpack' and leave the user with a traceback.
-rw-r--r-- | morphlib/buildbranch.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/morphlib/buildbranch.py b/morphlib/buildbranch.py index 09f6e104..2482bc9a 100644 --- a/morphlib/buildbranch.py +++ b/morphlib/buildbranch.py @@ -35,6 +35,15 @@ class BuildBranchCleanupError(cliapp.AppException): % locals()) +class NoReposError(cliapp.AppException): + def __init__(self, bb, ignored): + self.bb = bb + cliapp.AppException.__init__( + self, "No repos were found in system branch (ignored %i which " + "didn't have the right morph.uuid setting)" % (ignored)) + + + class BuildBranch(object): '''Represent the sources modified in a system branch. @@ -61,7 +70,7 @@ class BuildBranch(object): self._branch_root = sb.get_config('branch.root') branch_uuid = sb.get_config('branch.uuid') - for gd in sb.list_git_directories(): + for count, gd in enumerate(sb.list_git_directories()): try: repo_uuid = gd.get_config('morph.uuid') except cliapp.AppException: @@ -76,6 +85,9 @@ class BuildBranch(object): index.set_to_tree(gd.resolve_ref_to_tree(gd.HEAD)) self._to_push[gd] = (build_ref, index) + if len(self._to_push) == 0: + raise NoReposError(self, count) + rootinfo, = ((gd, index) for gd, (build_ref, index) in self._to_push.iteritems() if gd.get_config('morph.repository') == self._branch_root) |