From af40dad88ba1ff8bca692122e592ffe8ec0fa015 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 26 Aug 2026 19:31:50 -0400 Subject: [PATCH] Fix MRTarget equality to compare branch values MRTarget.__eq__() compared self.branch with itself instead of comparing it with other.branch, causing targets with the same repository but different branches to compare as equal. Correct the comparison and add a regression test verifying that gitlab_mr_targets_handled membership respects the configured branch. This ensures GitLab MR target matching does not incorrectly treat different branch patterns as the same target. Signed-off-by: Robin Getz --- packit_service/config.py | 2 +- tests/unit/test_config.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packit_service/config.py b/packit_service/config.py index e31ec365d..851830a2f 100644 --- a/packit_service/config.py +++ b/packit_service/config.py @@ -90,7 +90,7 @@ def __eq__(self, other: object) -> bool: if not isinstance(other, MRTarget): raise NotImplementedError() - return self.repo == other.repo and self.branch == self.branch + return self.repo == other.repo and self.branch == other.branch class ServiceConfig(Config): diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 6f7f81aa3..e6d326b0f 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -83,6 +83,14 @@ def test_parse_valid(service_config_valid): assert config.package_config_path_override is None +def test_mr_target_membership_respects_branch(service_config_valid): + config = ServiceConfig.get_from_dict(service_config_valid) + assert MRTarget("redhat/centos-stream/src/.+", "c9s") in config.gitlab_mr_targets_handled + assert ( + MRTarget("redhat/centos-stream/src/.+", "rawhide") not in config.gitlab_mr_targets_handled + ) + + def test_parse_optional_values(service_config_valid): """When optional values are set, they are correctly parsed""" config = ServiceConfig.get_from_dict(