proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/, /, tests/scripts/
"Arthur Zamarin" <[email protected]>
| Newsgroups | gmane.linux.gentoo.cvs |
|---|---|
| Message-ID | <1786699746.1803f474dde066428ba8404f0de6642bd24d28c4.arthurzam@gentoo> |
commit: 1803f474dde066428ba8404f0de6642bd24d28c4
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 14 09:29:06 2026 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 09:29:06 2026 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=1803f474
manifest: say when there was nothing to do
A run which found everything already current printed nothing and exited 0,
which is indistinguishable from one that silently ignored you, the
complaint behind both #80 and #108.
Report "manifests are up to date" when the operation got through without
reporting any work of its own, and pass the verbosity down so -v names each
package that was passed over and why. -q stays silent.
Resolves: https://github.com/pkgcore/pkgdev/issues/80
Resolves: https://github.com/pkgcore/pkgdev/issues/108
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
NEWS.rst | 4 ++++
src/pkgdev/scripts/pkgdev_manifest.py | 20 +++++++++++++++++++-
tests/scripts/test_pkgdev_manifest.py | 31 +++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/NEWS.rst b/NEWS.rst
index 51a9270..e2c4652 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -14,6 +14,10 @@ pkgdev 0.2.17 (unreleased)
**pkgdev manifest:**
+- manifest: a run with nothing to do now says so instead of printing nothing
+ at all, and ``-v`` names each package passed over and why (Arthur Zamarin,
+ #80, #108)
+
- manifest: any file inside a package directory now manifests that package,
so ``pkgdev manifest files/some.patch`` works rather than failing to parse
the path as an atom (Arthur Zamarin, #80)
diff --git a/src/pkgdev/scripts/pkgdev_manifest.py b/src/pkgdev/scripts/pkgdev_manifest.py
index 66257da..02389db 100644
--- a/src/pkgdev/scripts/pkgdev_manifest.py
+++ b/src/pkgdev/scripts/pkgdev_manifest.py
@@ -127,15 +127,33 @@ def _manifest_validate(parser, namespace):
namespace.restriction = packages.AndRestriction(*restrictions)
+class _ManifestObserver(observer_mod.formatter_output):
+ """Observer noting whether the operation reported doing anything."""
+
+ def __init__(self, out, verbosity=0):
+ super().__init__(out)
+ self.verbosity = verbosity
+ self.reported = False
+
+ def info(self, msg, *args, **kwds):
+ self.reported = True
+ super().info(msg, *args, **kwds)
+
+
@manifest.bind_main_func
def _manifest(options, out, err):
+ observer = _ManifestObserver(out, options.verbosity)
failed = options.repo.operations.manifest(
domain=options.domain,
restriction=options.restriction,
- observer=observer_mod.formatter_output(out),
+ observer=observer,
mirrors=options.mirrors,
force=options.force,
distdir=options.distdir,
)
+ # a silent run is indistinguishable from one which did nothing at all
+ if not failed and not observer.reported and options.verbosity >= 0:
+ out.write("manifests are up to date")
+
return int(any(failed))
diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py
index b02731e..4a0dfd8 100644
--- a/tests/scripts/test_pkgdev_manifest.py
+++ b/tests/scripts/test_pkgdev_manifest.py
@@ -189,6 +189,37 @@ class TestPkgdevManifest:
self.script()
assert excinfo.value.code == 0
out, err = capsys.readouterr()
+ assert err == ""
+ assert out.strip() == "manifests are up to date"
+
+ def test_target_within_pkgdir(self, capsys, repo):
+ """Any file inside a package dir manifests that package."""
+ repo.create_ebuild("cat/pkg-0")
+ pkgdir = os.path.dirname(repo.create_ebuild("cat/pkg-1"))
+ os.makedirs(pjoin(pkgdir, "files"), exist_ok=True)
+ touch(pjoin(pkgdir, "files", "a.patch"))
+ for target in ("files/a.patch", "files", "metadata.xml"):
+ touch(pjoin(pkgdir, "metadata.xml"))
+ with (
+ patch("sys.argv", self.args + [target]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(pkgdir),
+ ):
+ self.script()
+ assert excinfo.value.code == 0
+ out, err = capsys.readouterr()
+ assert err == ""
+
+ def test_good_manifest_quiet(self, capsys, repo):
+ repo.create_ebuild("cat/pkg-0")
+ with (
+ patch("sys.argv", self.args + ["-q"]),
+ pytest.raises(SystemExit) as excinfo,
+ chdir(repo.location),
+ ):
+ self.script()
+ assert excinfo.value.code == 0
+ out, err = capsys.readouterr()
assert out == err == ""
def test_target_within_pkgdir(self, capsys, repo):