Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop through all nested configs #335

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.5.2 (2024-06-22)

- Fixed logic to included all nested configs.

# 3.5.1 (2024-05-19)

- Updated nested config lookup to ignore build and package directories.
Expand Down
4 changes: 1 addition & 3 deletions gitman/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from . import common
from .decorators import preserve_cwd
from .models import Config, Source, find_nested_configs, load_config
from .models.config import filter_nested_configs


def init(*, force: bool = False):
Expand Down Expand Up @@ -93,7 +92,6 @@ def install(
config = load_config(root)
configs = [config] if config else []
configs.extend(find_nested_configs(root, depth, []))
configs = filter_nested_configs(configs)

if configs:
count = 0
Expand Down Expand Up @@ -277,7 +275,7 @@ def lock(*names, depth=None, root=None):
config = load_config(root)
configs = [config] if config else []
configs.extend(find_nested_configs(root, depth, []))
configs = filter_nested_configs(configs)

if configs:
count = 0
common.newline()
Expand Down
18 changes: 0 additions & 18 deletions gitman/models/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import sys
from pathlib import Path
from typing import Iterator, List, Optional

import log
Expand Down Expand Up @@ -465,20 +464,3 @@ def _valid_filename(filename):
if name.startswith("."):
name = name[1:]
return name in {"gitman", "gdm"} and ext in {".yml", ".yaml"}


def filter_nested_configs(configs: List[Config]) -> List[Config]:
"""Filter subdirectories inside of parent config."""
filtered_configs = []
for config_a in configs:
is_nested = False
for config_b in configs:
if config_a == config_b:
continue
if Path(config_b.location_path) in Path(config_a.location_path).parents:
is_nested = True
break
if not is_nested:
filtered_configs.append(config_a)

return filtered_configs
16 changes: 1 addition & 15 deletions gitman/tests/test_models_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import pytest
from expecter import expect

from gitman.models import Config, find_nested_configs, load_config
from gitman.models.config import filter_nested_configs
from gitman.models import Config, load_config

from .conftest import FILES

Expand Down Expand Up @@ -149,16 +148,3 @@ def test_load_from_directory_without_config_file(self, tmpdir):
config = load_config()

assert None is config

@pytest.mark.integration
def test_filter_nested_config(self):
"""Verify that filter_nested_config removes nested configs"""
config = load_config(FILES)
assert None is not config
count = config.install_dependencies(depth=2)
assert 5 == count
configs = [config] if config else []
configs.extend(find_nested_configs(FILES, depth=2, skip_paths=[]))
assert 2 == len(configs)
configs = filter_nested_configs(configs)
assert 1 == len(configs)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]

name = "gitman"
version = "3.5.1"
version = "3.5.2"
description = "A language-agnostic dependency manager using Git."

license = "MIT"
Expand Down
Loading