From 3c760870b56913d397b0b6f17546876f8620f120 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 1 Jan 2021 11:12:47 +0100 Subject: [PATCH] [FIX] runbot: bug in duplicate module detection The test in the original code will never fire because the value searched for is not in the keys of the dictionary, but in one of the lists which are in the values. Work around this by maintaining a reverse dictionary module name -> commit and use this for the test. --- runbot/models/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index 853efa41..5ddfe6ba 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -768,18 +768,23 @@ class BuildResult(models.Model): return exports def _get_available_modules(self): + all_modules = dict() available_modules = defaultdict(list) # repo_modules = [] for commit in self.env.context.get('defined_commit_ids') or self.params_id.commit_ids: for (addons_path, module, manifest_file_name) in commit._get_available_modules(): - if module in available_modules: + if module in all_modules: self._log( 'Building environment', - '%s is a duplicated modules (found in "%s")' % (module, commit._source_path(addons_path, module, manifest_file_name)), + '%s is a duplicated modules (found in "%s", already defined in %s)' % ( + module, + commit._source_path(addons_path, module, manifest_file_name), + all_modules[module]._source_path(addons_path, module, manifest_file_name)), level='WARNING' ) else: available_modules[commit.repo_id].append(module) + all_modules[module] = commit # return repo_modules, available_modules return available_modules