[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.
This commit is contained in:
Alexandre Fayolle 2021-01-01 11:12:47 +01:00 committed by xdo
parent 0a37ff2f90
commit 3c760870b5

View File

@ -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