fix(scm_provider): ensure mixed repo/branch filter conditions are ANDed correctly #26086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
repositoryMatchwas ignored when combined with branch-level conditions likepathsExist,pathsDoNotExist, orbranchMatch.The Problem
SCM Provider filtering operates in two phases:
Previously,
getApplicableFilterscategorized filters based solely on theirFilterTypeenum. A filter with bothrepositoryMatch(repo-level) ANDpathsExist(branch-level) would only be placed in the branch filter group, causing therepositoryMatchcondition to never be evaluated.The Fix
getApplicableFiltersnow inspects the actual conditions present in each filter rather than relying on theFilterTypeenum. Filters with mixed conditions are added to both filter groups.matchFilternow accepts aphaseparameter to evaluate only the conditions relevant to the current filtering phase:FilterTypeRepophase → checksrepositoryMatchandlabelMatchFilterTypeBranchphase → checksbranchMatch,pathsExist, andpathsDoNotExistExample
Before: All repos with
config/app.yamlmatched (repositoryMatch ignored)After: Only repos starting with
eks-AND containingconfig/app.yamlmatchThis fix changes the behavior of filters that combine repo-level and branch-level conditions. Previously, repo-level conditions (
repositoryMatch,labelMatch) were silently ignored when combined with branch-level conditions (branchMatch,pathsExist,pathsDoNotExist).If you have filters like this:
Before: Matched all repos containing
config/app.yaml(repositoryMatch was ignored)After: Correctly matches only repos starting with
eks-that also containconfig/app.yamlMigration