diff --git a/dep_freshness/_tables.py b/dep_freshness/_tables.py index 3eabe3e..ed000ff 100644 --- a/dep_freshness/_tables.py +++ b/dep_freshness/_tables.py @@ -93,7 +93,6 @@ MANIFEST_GLOBS: Final = ( ".fvmrc", ".nvmrc", ".python-version", - "libs.versions.toml", "gradle-wrapper.properties", ) REQUIREMENTS_PATTERN: Final = r"^requirements.*\.txt$" diff --git a/dep_freshness/discover.py b/dep_freshness/discover.py index 3bf16b3..0ce796b 100644 --- a/dep_freshness/discover.py +++ b/dep_freshness/discover.py @@ -36,7 +36,6 @@ _BY_NAME = { ".fvmrc": fvm.parse, ".nvmrc": javascript.parse_nvmrc, ".python-version": python.parse_python_version, - gradle.CATALOG_NAME: gradle.parse_catalog, gradle.WRAPPER_NAME: gradle.parse_wrapper, } @@ -46,6 +45,7 @@ def is_manifest(path: Path) -> bool: path.name in MANIFEST_GLOBS or bool(_REQUIREMENTS.match(path.name)) or workflow.is_workflow(path) + or gradle.is_catalog(path) ) @@ -58,6 +58,8 @@ def parse_manifest(path: Path) -> list[Dep]: return python.parse_requirements(path) if workflow.is_workflow(path): return workflow.parse(path) + if gradle.is_catalog(path): + return gradle.parse_catalog(path) return [] @@ -68,7 +70,9 @@ def _git_ignored(paths: list[Path], root: Path) -> set[Path]: result = subprocess.run( ["git", "-C", str(root), "check-ignore", "--stdin"], input="\n".join(str(p) for p in paths), - capture_output=True, text=True, check=False, + capture_output=True, + text=True, + check=False, ) except OSError: return set() diff --git a/dep_freshness/parsers/gradle.py b/dep_freshness/parsers/gradle.py index 1bba9cf..ce3fb0a 100644 --- a/dep_freshness/parsers/gradle.py +++ b/dep_freshness/parsers/gradle.py @@ -2,6 +2,8 @@ The version catalog is the one place a Gradle build should declare versions, which makes it a manifest the gate can read without evaluating Kotlin DSL. +A build may have several (`settings.gradle.kts` can `from(files(...))` any +`*.versions.toml`; TachiyomiSY has three), so the suffix is what is matched. Three shapes appear in `[libraries]` and `[plugins]`: foo = "group:artifact:1.2.3" # inline string @@ -36,7 +38,7 @@ from dep_freshness.models import Dep from dep_freshness.parsers._lines import index from dep_freshness.versions import exact_pin -CATALOG_NAME = "libs.versions.toml" +CATALOG_SUFFIX = ".versions.toml" # libs.versions.toml, but also sy.versions.toml WRAPPER_NAME = "gradle-wrapper.properties" _DISTRIBUTION = re.compile( r"gradle-(?P\d+(?:\.\d+)*(?:-[0-9A-Za-z.-]+?)?)-(?:bin|all)\.zip" @@ -137,3 +139,8 @@ def parse_wrapper(path: Path) -> list[Dep]: ) ] return [] + + +def is_catalog(path: Path) -> bool: + """True for `libs.versions.toml` and any sibling catalog a build declares.""" + return path.name.endswith(CATALOG_SUFFIX) diff --git a/dep_freshness/templates/precommit-hook.yaml b/dep_freshness/templates/precommit-hook.yaml index c7a5457..dad7a93 100644 --- a/dep_freshness/templates/precommit-hook.yaml +++ b/dep_freshness/templates/precommit-hook.yaml @@ -18,5 +18,5 @@ |package\.json|package-lock\.json|pnpm-lock\.yaml |Cargo\.(toml|lock)|go\.(mod|sum) |\.fvmrc|\.nvmrc|\.python-version - |libs\.versions\.toml|gradle-wrapper\.properties + |\.versions\.toml|gradle-wrapper\.properties |\.github/workflows/.*\.ya?ml)$ diff --git a/dep_freshness/templates/workflow.yml b/dep_freshness/templates/workflow.yml index 856c6e7..bc145ee 100644 --- a/dep_freshness/templates/workflow.yml +++ b/dep_freshness/templates/workflow.yml @@ -57,7 +57,7 @@ jobs: key: dep-freshness-${{ hashFiles('**/pubspec.yaml', '**/pyproject.toml', '**/requirements*.txt', '**/package.json', '**/Cargo.toml', '**/go.mod', - '**/libs.versions.toml') }} + '**/*.versions.toml') }} restore-keys: dep-freshness- - name: Every dependency is on newest stable diff --git a/dep_freshness/tests/test_discover.py b/dep_freshness/tests/test_discover.py index 2985755..ebbf7c3 100644 --- a/dep_freshness/tests/test_discover.py +++ b/dep_freshness/tests/test_discover.py @@ -15,7 +15,8 @@ PUBSPEC = "name: demo\ndependencies:\n http: 1.6.0\n" @pytest.mark.parametrize("name", [ "pubspec.yaml", "pyproject.toml", "package.json", "Cargo.toml", "go.mod", ".fvmrc", ".nvmrc", ".python-version", "requirements.txt", - "requirements-dev.txt", "libs.versions.toml", "gradle-wrapper.properties", + "requirements-dev.txt", "libs.versions.toml", "sy.versions.toml", + "gradle-wrapper.properties", ]) def test_manifest_names_are_recognised(name): assert is_manifest(Path(name))