Commit cfd1e81e authored by Mathieu Coupé's avatar Mathieu Coupé
Browse files

fix: handle case of shared project which path are be outside initial group path

parent 25134347
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -186,6 +186,10 @@ class Butler:
        return "" if path == self.group_path else path[len(self.group_path) + 1 :]

    def is_excluded(self, path: str) -> bool:
        # in case of shared projects, the project path will likely be outside initial group path
        if not path.startswith(self.group_path):
            return  True

        return self.rel_path(path) in self.exclude

    def load_cfg(self, project: Project) -> ButlerCfg:
+3 −0
Original line number Diff line number Diff line
@@ -104,17 +104,20 @@ class TestBasic:
        butler.exclude = []
        assert butler.is_excluded("path/to/group") is False
        assert butler.is_excluded("path/to/group/project") is False
        assert butler.is_excluded("shared/project") is True

        # exclude array contains project
        butler.exclude = ["project"]
        assert butler.is_excluded("path/to/group") is False
        assert butler.is_excluded("path/to/group/project") is True
        assert butler.is_excluded("shared/project") is True

        # exclude array contains subgroup
        butler.exclude = ["subgroup"]
        assert butler.is_excluded("path/to/group") is False
        assert butler.is_excluded("path/to/group/subgroup") is True
        assert butler.is_excluded("path/to/group/subgroup/project") is False
        assert butler.is_excluded("shared/project") is True

    @responses.activate
    def test_load_cfg(self) -> None: