diff options
-rw-r--r-- | src/pkgdev/scripts/pkgdev_manifest.py | 17 | ||||
-rw-r--r-- | tests/scripts/test_pkgdev_manifest.py | 24 |
2 files changed, 36 insertions, 5 deletions
diff --git a/src/pkgdev/scripts/pkgdev_manifest.py b/src/pkgdev/scripts/pkgdev_manifest.py index 76dc69a..97e6e22 100644 --- a/src/pkgdev/scripts/pkgdev_manifest.py +++ b/src/pkgdev/scripts/pkgdev_manifest.py @@ -3,7 +3,7 @@ import re import subprocess from pkgcore.operations import observer as observer_mod -from pkgcore.restrictions import packages +from pkgcore.restrictions import packages, values from pkgcore.util.parserestrict import parse_match from snakeoil.cli import arghparse @@ -52,6 +52,13 @@ manifest_opts.add_argument( In addition to matching the specified restriction, restrict to targets which are marked as modified by git, including untracked files. """) +manifest_opts.add_argument( + '--ignore-fetch-restricted', dest='ignore_fetch_restricted', help='Ignore fetch restricted ebuilds', + action='store_true', + docs=""" + Ignore attempting to update manifest entries for ebuilds which are + fetch restricted. + """) def _restrict_targets(repo, targets): @@ -86,10 +93,12 @@ def _restrict_modified_files(repo): def _manifest_validate(parser, namespace): targets = namespace.target if namespace.target else [namespace.cwd] - namespace.restriction = _restrict_targets(namespace.repo, targets) + restrictions = [_restrict_targets(namespace.repo, targets)] if namespace.if_modified: - namespace.restriction = packages.AndRestriction(namespace.restriction, - _restrict_modified_files(namespace.repo)) + restrictions.append(_restrict_modified_files(namespace.repo)) + if namespace.ignore_fetch_restricted: + restrictions.append(packages.PackageRestriction('restrict', values.ContainmentMatch('fetch', negate=True))) + namespace.restriction = packages.AndRestriction(*restrictions) @manifest.bind_main_func diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py index 696a2f2..5787770 100644 --- a/tests/scripts/test_pkgdev_manifest.py +++ b/tests/scripts/test_pkgdev_manifest.py @@ -1,5 +1,5 @@ from functools import partial -from typing import Set +from typing import List, Set from unittest.mock import patch import pytest @@ -94,6 +94,28 @@ class TestPkgdevManifestParseArgs: git_repo.remove(ebuild_path, commit=False) assert manifest_matches() == set() + def test_ignore_fetch_restricted(self, repo, tool): + def manifest_matches() -> List[str]: + with chdir(repo.location): + options, _ = tool.parse_args(['manifest', '--ignore-fetch-restricted']) + return [x.cpvstr for x in repo.itermatch(options.restriction)] + + # No RESTRICT + repo.create_ebuild('cat/pkg-0') + assert manifest_matches() == ['cat/pkg-0'] + + # Not fetch RESTRICT + repo.create_ebuild('cat/pkg-0', restrict=('mirror')) + assert manifest_matches() == ['cat/pkg-0'] + + # fetch RESTRICT + repo.create_ebuild('cat/pkg-0', restrict=('fetch')) + assert manifest_matches() == [] + + # Multiple RESTRICT + repo.create_ebuild('cat/pkg-0', restrict=('mirror', 'fetch')) + assert manifest_matches() == [] + def test_non_repo_dir_target(self, tmp_path, repo, capsys, tool): with pytest.raises(SystemExit) as excinfo, \ chdir(repo.location): |