Skip to content

Commit f7b90de

Browse files
committed
pkgdev manifest: add --ignore-fetch-restricted
Resolves: #64 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 9ed5db0 commit f7b90de

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

src/pkgdev/scripts/pkgdev_manifest.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import subprocess
44

55
from pkgcore.operations import observer as observer_mod
6-
from pkgcore.restrictions import packages
6+
from pkgcore.restrictions import packages, values
77
from pkgcore.util.parserestrict import parse_match
88
from snakeoil.cli import arghparse
99

@@ -52,6 +52,13 @@
5252
In addition to matching the specified restriction, restrict to targets
5353
which are marked as modified by git, including untracked files.
5454
""")
55+
manifest_opts.add_argument(
56+
'--ignore-fetch-restricted', dest='ignore_fetch_restricted', help='Ignore fetch restricted ebuilds',
57+
action='store_true',
58+
docs="""
59+
Ignore attempting to update manifest entries for ebuilds which are
60+
fetch restricted.
61+
""")
5562

5663

5764
def _restrict_targets(repo, targets):
@@ -86,10 +93,12 @@ def _restrict_modified_files(repo):
8693
def _manifest_validate(parser, namespace):
8794
targets = namespace.target if namespace.target else [namespace.cwd]
8895

89-
namespace.restriction = _restrict_targets(namespace.repo, targets)
96+
restrictions = [_restrict_targets(namespace.repo, targets)]
9097
if namespace.if_modified:
91-
namespace.restriction = packages.AndRestriction(namespace.restriction,
92-
_restrict_modified_files(namespace.repo))
98+
restrictions.append(_restrict_modified_files(namespace.repo))
99+
if namespace.ignore_fetch_restricted:
100+
restrictions.append(packages.PackageRestriction('restrict', values.ContainmentMatch('fetch', negate=True)))
101+
namespace.restriction = packages.AndRestriction(*restrictions)
93102

94103

95104
@manifest.bind_main_func

tests/scripts/test_pkgdev_manifest.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import partial
2-
from typing import Set
2+
from typing import List, Set
33
from unittest.mock import patch
44

55
import pytest
@@ -94,6 +94,28 @@ def manifest_matches() -> Set[str]:
9494
git_repo.remove(ebuild_path, commit=False)
9595
assert manifest_matches() == set()
9696

97+
def test_ignore_fetch_restricted(self, repo, tool):
98+
def manifest_matches() -> List[str]:
99+
with chdir(repo.location):
100+
options, _ = tool.parse_args(['manifest', '--ignore-fetch-restricted'])
101+
return [x.cpvstr for x in repo.itermatch(options.restriction)]
102+
103+
# No RESTRICT
104+
repo.create_ebuild('cat/pkg-0')
105+
assert manifest_matches() == ['cat/pkg-0']
106+
107+
# Not fetch RESTRICT
108+
repo.create_ebuild('cat/pkg-0', restrict=('mirror'))
109+
assert manifest_matches() == ['cat/pkg-0']
110+
111+
# fetch RESTRICT
112+
repo.create_ebuild('cat/pkg-0', restrict=('fetch'))
113+
assert manifest_matches() == []
114+
115+
# Multiple RESTRICT
116+
repo.create_ebuild('cat/pkg-0', restrict=('mirror', 'fetch'))
117+
assert manifest_matches() == []
118+
97119
def test_non_repo_dir_target(self, tmp_path, repo, capsys, tool):
98120
with pytest.raises(SystemExit) as excinfo, \
99121
chdir(repo.location):

0 commit comments

Comments
 (0)