Skip to content

Commit

Permalink
Ignore folders that are not valid namaspeces
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 10, 2023
1 parent e5e06b4 commit beb45ee
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,17 @@ def install_requirements( # noqa: C901
def search_galaxy_paths(self, search_dir: Path, depth: int = 0) -> list[str]:
"""Search for galaxy paths (only one level deep)."""
galaxy_paths: list[str] = []
for file in os.listdir(search_dir):
file_path = Path(file)
if file_path.is_dir() and depth < 1:
galaxy_paths.extend(self.search_galaxy_paths(file_path, 1))
elif fnmatch.fnmatch(file, "galaxy.yml"):
galaxy_paths.append(str(search_dir / file))
if depth == 0 and not galaxy_paths:
return ["galaxy.yml"]
# look only in folders that are valid namespaces
# https://galaxy.ansible.com/docs/contributing/namespaces.html#namespace-limitations
if re.match(r"^[a-z\d][a-z\d_]+$", search_dir.name):
for file in os.listdir(search_dir):
file_path = Path(file)
if file_path.is_dir() and depth < 1:
galaxy_paths.extend(self.search_galaxy_paths(file_path, 1))
elif fnmatch.fnmatch(file, "galaxy.yml"):
galaxy_paths.append(str(search_dir / file))
if depth == 0 and not galaxy_paths:
return ["galaxy.yml"]
return galaxy_paths

def prepare_environment( # noqa: C901
Expand Down

0 comments on commit beb45ee

Please sign in to comment.