Filter excluded project branches after fetching

The flags specified when fetching project branches only determine
whether the returned info is valid for the given query.

However, we still need to filter the branch info based on the needed
flags as we already do when we get the branch info from the cache.

This fixes a bug where configuration could be incorrectly loaded from a
locked branch when we don't have the data already in the cache, even
when the `exclude-locked-branches` option was set to True. This can also
happen during tenant validate as we always starts with an empty cache
there.

Change-Id: Ia4992e55d1f0448d98667cbfd71ba033c966918e
This commit is contained in:
Simon Westphahl
2025-02-18 14:09:59 +01:00
parent 9642676e99
commit 4834cab67a

View File

@ -368,7 +368,9 @@ class ZKBranchCacheMixin:
self._branch_cache.setProjectBranches(
project.name, valid_flags, branch_infos)
return sorted(bi.name for bi in branch_infos)
branches = [b.name for b in self._filterProjectBranches(
branch_infos, exclude_unprotected, exclude_locked)]
return sorted(branches)
def getProjectMergeModes(self, project, tenant, min_ltime=-1):
"""Get the merge modes for the given project.