Return projects that contain at least one changed path.
(
projects: Iterable[Project], paths: Iterable[str]
)
| 144 | |
| 145 | |
| 146 | def projects_for_changed_files( |
| 147 | projects: Iterable[Project], paths: Iterable[str] |
| 148 | ) -> list[Project]: |
| 149 | """Return projects that contain at least one changed path.""" |
| 150 | |
| 151 | by_path = {project.path: project for project in projects} |
| 152 | selected: dict[str, Project] = {} |
| 153 | for changed_path in paths: |
| 154 | for project_path, project in by_path.items(): |
| 155 | if changed_path == project_path or changed_path.startswith( |
| 156 | f"{project_path}/" |
| 157 | ): |
| 158 | selected[project_path] = project |
| 159 | return sorted(selected.values(), key=lambda project: project.path) |
| 160 | |
| 161 | |
| 162 | def validate_project(repo_root: Path, project: str) -> int: |
no outgoing calls