public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/
@ 2022-10-14 19:36 Arthur Zamarin
  0 siblings, 0 replies; 6+ messages in thread
From: Arthur Zamarin @ 2022-10-14 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     6cf5a11fc6ff12af7c62e13329694f3c22a5e32d
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 14 19:21:07 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Oct 14 19:34:13 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=6cf5a11f

manifest: better handling of path target

When passing a `.` path while inside a package directory, it passed to
path restrict generator as a simple path, which resulted in broken
restrict which collected all ebuilds in the repository.

By using `os.path.relpath` to base of repository, we make sure the
correct path is passed and the correct restricts are generated.

Fixes: https://github.com/pkgcore/pkgdev/issues/85
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_manifest.py |  2 ++
 tests/scripts/test_pkgdev_manifest.py | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/pkgdev/scripts/pkgdev_manifest.py b/src/pkgdev/scripts/pkgdev_manifest.py
index de36fcc..229238c 100644
--- a/src/pkgdev/scripts/pkgdev_manifest.py
+++ b/src/pkgdev/scripts/pkgdev_manifest.py
@@ -66,6 +66,8 @@ def _restrict_targets(repo, targets):
     for target in targets:
         if os.path.exists(target):
             try:
+                if target in repo:
+                    target = os.path.relpath(target, repo.location)
                 restrictions.append(repo.path_restrict(target))
             except ValueError as exc:
                 manifest.error(exc)

diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py
index 0c1c8c8..2800236 100644
--- a/tests/scripts/test_pkgdev_manifest.py
+++ b/tests/scripts/test_pkgdev_manifest.py
@@ -24,6 +24,38 @@ class TestPkgdevManifestParseArgs:
         matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
         assert matches == ['cat/pkg-0']
 
+    def test_repo_relative_pkg(self, repo, capsys, tool):
+        repo.create_ebuild('cat/pkg-0')
+        repo.create_ebuild('cat/newpkg-0')
+        with chdir(pjoin(repo.location, 'cat/pkg')):
+            options, _ = tool.parse_args(['manifest', '.'])
+        matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
+        assert matches == ['cat/pkg-0']
+
+    def test_repo_relative_category(self, repo, capsys, tool):
+        repo.create_ebuild('cat/pkg-0')
+        repo.create_ebuild('cat/newpkg-0')
+
+        with chdir(pjoin(repo.location, 'cat')):
+            options, _ = tool.parse_args(['manifest', 'pkg'])
+        matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
+        assert matches == ['cat/pkg-0']
+
+        with chdir(pjoin(repo.location, 'cat')):
+            options, _ = tool.parse_args(['manifest', '.'])
+        matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
+        assert set(matches) == {'cat/pkg-0', 'cat/newpkg-0'}
+
+    def test_repo_relative_outside(self, tmp_path, repo, capsys, tool):
+        repo.create_ebuild('cat/pkg-0')
+        (ebuild := tmp_path / 'pkg.ebuild').touch()
+        with pytest.raises(SystemExit) as excinfo:
+            with chdir(repo.location):
+                tool.parse_args(['manifest', str(ebuild)])
+        assert excinfo.value.code == 2
+        out, err = capsys.readouterr()
+        assert err.strip() == f"pkgdev manifest: error: {repo.repo_id!r} repo doesn't contain: {str(ebuild)!r}"
+
     def test_dir_target(self, repo, capsys, tool):
         repo.create_ebuild('cat/pkg-0')
         with chdir(repo.location):


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/
@ 2022-10-16 17:31 Arthur Zamarin
  0 siblings, 0 replies; 6+ messages in thread
From: Arthur Zamarin @ 2022-10-16 17:31 UTC (permalink / raw
  To: gentoo-commits

commit:     729947acaa9bb071936c4d68fa1dfe86628f2d26
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 16 17:27:36 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 16 17:27:36 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=729947ac

commit: don't show disable for targets that are no-op

For PYTHON_COMPAT, LUA_COMPAT and USE_RUBY, show the "disable" target
after "enable" only if this target exists. For example, if I enable
py3.11 and disable py3.7 (which is no-op), it will show only "enable
py3.11". If there is no "enable", it will still show "disable py3.7".

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_commit.py | 10 +++++++---
 tests/scripts/test_pkgdev_commit.py | 23 +++++++++++++++--------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index 20fd471..0cdf232 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -443,6 +443,7 @@ class PkgSummary(ChangeSummary):
                 watch_vars = {'HOMEPAGE', 'DESCRIPTION', 'LICENSE', 'SRC_URI'}
                 array_targets = {'PYTHON_COMPAT', 'LUA_COMPAT'}
                 string_targets = {'USE_RUBY'}
+                use_expand_mapping = {'PYTHON_COMPAT': 'python_targets', 'LUA_COMPAT': 'lua_targets', 'USE_RUBY': 'ruby_targets'}
                 targets = array_targets | string_targets
 
                 updated_vars = drop.keys() & add.keys()
@@ -450,9 +451,11 @@ class PkgSummary(ChangeSummary):
                     return f"update {', '.join(updated)}"
                 elif (target := targets & updated_vars) and len(target) == 1:
                     target = next(iter(target))
+                    py_re = lambda x: re.sub(r'^python(\d+)_(\d+)$', r'py\1.\2', x)
+                    use_expand = {py_re(use[len(target)+2:])
+                        for use, _ in self.repo.use_expand_desc[use_expand_mapping[target]]}
                     if target in array_targets:
                         array_re = re.compile(r'\[\d+\]="(?P<val>.+?)"')
-                        py_re = lambda x: re.sub(r'^python(\d+)_(\d+)$', r'py\1.\2', x)
                         old = {py_re(m.group('val')) for m in re.finditer(array_re, drop[target])}
                         new = {py_re(m.group('val')) for m in re.finditer(array_re, add[target])}
                     else:
@@ -462,8 +465,9 @@ class PkgSummary(ChangeSummary):
                     msg = []
                     if added := sorted(new - old):
                         msg.append(f"enable {', '.join(added)}")
-                    if dropped := sorted(old - new):
-                        msg.append(f"disable {', '.join(dropped)}")
+                    if dropped := old - new:
+                        if not msg or (dropped := dropped.intersection(use_expand)):
+                            msg.append(f"disable {', '.join(sorted(dropped))}")
                     msg = ' and '.join(msg)
                     if len(msg) <= 50:
                         return msg

diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py
index f920054..efc9491 100644
--- a/tests/scripts/test_pkgdev_commit.py
+++ b/tests/scripts/test_pkgdev_commit.py
@@ -479,6 +479,9 @@ class TestPkgdevCommit:
         assert commit() == 'cat/pkg: update DESCRIPTION, HOMEPAGE'
 
         # update string_targets (USE_RUBY)
+        os.mkdir(pjoin(repo.location, 'profiles', 'desc'))
+        with open(pjoin(repo.path, 'profiles', 'desc', 'ruby_targets.desc'), 'w') as file:
+            file.write('\n'.join(f'ruby{ver} - stub' for ver in range(27, 40)))
         repo.create_ebuild('cat/pkg-8', use_ruby='ruby27')
         git_repo.add_all('cat/pkg-8')
         repo.create_ebuild('cat/pkg-8', use_ruby='ruby27 ruby30')
@@ -489,12 +492,16 @@ class TestPkgdevCommit:
         assert commit() == 'cat/pkg: update USE_RUBY support'
 
         # update array_targets (PYTHON_COMPAT)
-        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_9 )')
+        with open(pjoin(repo.path, 'profiles', 'desc', 'python_targets.desc'), 'w') as file:
+            file.write('\n'.join(f'python3_{ver} - stub' for ver in (10, 11)))
+        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_8 python3_9 )')
         git_repo.add_all('cat/pkg-9')
-        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_{9..10} )')
+        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_{8..10} )')
         assert commit() == 'cat/pkg: enable py3.10'
-        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_10 )')
-        assert commit() == 'cat/pkg: disable py3.9'
+        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_{9..10} )')
+        assert commit() == 'cat/pkg: disable py3.8'
+        repo.create_ebuild('cat/pkg-9', data='PYTHON_COMPAT=( python3_{10..11} )')
+        assert commit() == 'cat/pkg: enable py3.11'
 
 
         # multiple ebuild modifications don't get a generated summary
@@ -508,12 +515,12 @@ class TestPkgdevCommit:
         assert commit() == 'cat/pkg: add versions'
 
         # create Manifest
-        with open(pjoin(git_repo.path, 'cat/pkg/Manifest'), 'w') as f:
-            f.write('DIST pkg-3.tar.gz 101 BLAKE2B deadbeef SHA512 deadbeef\n')
+        with open(pjoin(git_repo.path, 'cat/pkg/Manifest'), 'w') as file:
+            file.write('DIST pkg-3.tar.gz 101 BLAKE2B deadbeef SHA512 deadbeef\n')
         assert commit() == 'cat/pkg: update Manifest'
         # update Manifest
-        with open(pjoin(git_repo.path, 'cat/pkg/Manifest'), 'a+') as f:
-            f.write('DIST pkg-2.tar.gz 101 BLAKE2B deadbeef SHA512 deadbeef\n')
+        with open(pjoin(git_repo.path, 'cat/pkg/Manifest'), 'a+') as file:
+            file.write('DIST pkg-2.tar.gz 101 BLAKE2B deadbeef SHA512 deadbeef\n')
         assert commit() == 'cat/pkg: update Manifest'
         # remove Manifest
         os.remove(pjoin(git_repo.path, 'cat/pkg/Manifest'))


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/
@ 2023-08-24 18:14 Arthur Zamarin
  0 siblings, 0 replies; 6+ messages in thread
From: Arthur Zamarin @ 2023-08-24 18:14 UTC (permalink / raw
  To: gentoo-commits

commit:     047ac2bdcfe019107b13646825818a0bc5339b9d
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 24 17:25:48 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 24 17:48:51 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=047ac2bd

push: `--ask` stops for confirmation on warnings

Resolves: https://github.com/pkgcore/pkgdev/issues/150
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_push.py |  9 ++++++++-
 tests/scripts/test_pkgdev_push.py | 23 +++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_push.py b/src/pkgdev/scripts/pkgdev_push.py
index 7948336..cf510ab 100644
--- a/src/pkgdev/scripts/pkgdev_push.py
+++ b/src/pkgdev/scripts/pkgdev_push.py
@@ -2,6 +2,7 @@ import argparse
 import shlex
 
 from pkgcheck import reporters, scan
+from pkgcheck.results import Warning as PkgcheckWarning
 from snakeoil.cli import arghparse
 from snakeoil.cli.input import userquery
 
@@ -58,9 +59,12 @@ def _push(options, out, err):
 
     # scan commits for QA issues
     pipe = scan(options.scan_args)
+    has_warnings = False
     with reporters.FancyReporter(out) as reporter:
         for result in pipe:
             reporter.report(result)
+            if result.level == PkgcheckWarning.level:
+                has_warnings = True
 
     # fail on errors unless they're ignored
     if pipe.errors:
@@ -68,7 +72,10 @@ def _push(options, out, err):
             out.write(out.bold, out.fg("red"), "\nFAILURES", out.reset)
             for result in sorted(pipe.errors):
                 reporter.report(result)
-        if not (options.ask and userquery("Push commits anyway?", out, err)):
+        if not (options.ask and userquery("Push commits anyway?", out, err, default_answer=False)):
+            return 1
+    elif has_warnings and options.ask:
+        if not userquery("warnings detected, push commits anyway?", out, err, default_answer=False):
             return 1
 
     # push commits upstream

diff --git a/tests/scripts/test_pkgdev_push.py b/tests/scripts/test_pkgdev_push.py
index f1f0a0b..fb4faa3 100644
--- a/tests/scripts/test_pkgdev_push.py
+++ b/tests/scripts/test_pkgdev_push.py
@@ -124,3 +124,26 @@ class TestPkgdevPush:
         ), pytest.raises(SystemExit) as excinfo, chdir(self.child_git_repo.path):
             self.script()
         assert excinfo.value.code == 0
+
+    def test_warnings(self, capsys):
+        pkgdir = os.path.dirname(self.child_repo.create_ebuild("cat/pkg-1"))
+        os.makedirs((filesdir := pjoin(pkgdir, "files")), exist_ok=True)
+        with open(pjoin(filesdir, "foo"), "w") as f:
+            f.write("")
+        self.child_git_repo.add_all("cat/pkg-1")
+
+        # scans with warnings ask for confirmation before pushing with "--ask"
+        with patch("sys.argv", self.args + ["--ask"]), patch(
+            "sys.stdin", StringIO("n\n")
+        ), pytest.raises(SystemExit) as excinfo, chdir(self.child_git_repo.path):
+            self.script()
+        assert excinfo.value.code == 1
+        out, err = capsys.readouterr()
+        assert "EmptyFile" in out
+
+        # but without "--ask" it still pushes
+        with patch("sys.argv", self.args), pytest.raises(SystemExit) as excinfo, chdir(
+            self.child_git_repo.path
+        ):
+            self.script()
+        assert excinfo.value.code == 0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/
@ 2023-12-15 11:21 Arthur Zamarin
  0 siblings, 0 replies; 6+ messages in thread
From: Arthur Zamarin @ 2023-12-15 11:21 UTC (permalink / raw
  To: gentoo-commits

commit:     290143b24bab7ccc2f083395e13bd188132b54be
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 15 11:20:49 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 15 11:20:49 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=290143b2

bugs: mention age of packages in the bug description

Resolves: https://github.com/pkgcore/pkgdev/issues/140
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 28 ++++++++++++++++++++++++----
 tests/scripts/test_pkgdev_bugs.py |  6 +++---
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index e6cac18..924e9e4 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -5,6 +5,7 @@ import json
 import sys
 import urllib.request as urllib
 from collections import defaultdict
+from datetime import datetime
 from functools import partial
 from itertools import chain
 from pathlib import Path
@@ -13,6 +14,7 @@ from urllib.parse import urlencode
 from pkgcheck import const as pkgcheck_const
 from pkgcheck.addons import ArchesAddon, init_addon
 from pkgcheck.addons.profiles import ProfileAddon
+from pkgcheck.addons.git import GitAddon, GitModifiedRepo
 from pkgcheck.checks import visibility
 from pkgcheck.scripts import argparse_actions
 from pkgcore.ebuild.atom import atom
@@ -113,6 +115,7 @@ bugs_state.add_argument(
 )
 
 ArchesAddon.mangle_argparser(bugs)
+GitAddon.mangle_argparser(bugs)
 ProfileAddon.mangle_argparser(bugs)
 
 
@@ -199,13 +202,18 @@ class GraphNode:
                 keywords.add("*")
 
     def file_bug(
-        self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int], observer=None
+        self,
+        api_key: str,
+        auto_cc_arches: frozenset[str],
+        block_bugs: list[int],
+        modified_repo: multiplex.tree,
+        observer=None,
     ) -> int:
         if self.bugno is not None:
             return self.bugno
         for dep in self.edges:
             if dep.bugno is None:
-                dep.file_bug(api_key, auto_cc_arches, (), observer)
+                dep.file_bug(api_key, auto_cc_arches, (), modified_repo, observer)
         maintainers = dict.fromkeys(
             maintainer.email for pkg, _ in self.pkgs for maintainer in pkg.maintainers
         )
@@ -219,6 +227,17 @@ class GraphNode:
         if len(summary) > 90 and len(self.pkgs) > 1:
             summary = f"{self.pkgs[0][0].versioned_atom.cpvstr} and friends: stablereq"
 
+        description = ["Please stabilize", ""]
+        if modified_repo is not None:
+            for pkg, _ in self.pkgs:
+                with contextlib.suppress(StopIteration):
+                    match = next(modified_repo.itermatch(pkg.versioned_atom))
+                    added = datetime.fromtimestamp(match.time)
+                    days_old = (datetime.today() - added).days
+                    description.append(
+                        f" {pkg.versioned_atom.cpvstr}: no change for {days_old} days, since {added:%Y-%m-%d}"
+                    )
+
         request_data = dict(
             Bugzilla_api_key=api_key,
             product="Gentoo Linux",
@@ -226,7 +245,7 @@ class GraphNode:
             severity="enhancement",
             version="unspecified",
             summary=summary,
-            description="Please stabilize",
+            description="\n".join(description).strip(),
             keywords=keywords,
             cf_stabilisation_atoms="\n".join(self.lines()),
             assigned_to=maintainers[0],
@@ -505,8 +524,9 @@ class DependencyGraph:
             )
             self.out.flush()
 
+        modified_repo = init_addon(GitAddon, self.options).cached_repo(GitModifiedRepo)
         for node in self.starting_nodes:
-            node.file_bug(api_key, auto_cc_arches, block_bugs, observe)
+            node.file_bug(api_key, auto_cc_arches, block_bugs, modified_repo, observe)
 
 
 def _load_from_stdin(out: Formatter, err: Formatter):

diff --git a/tests/scripts/test_pkgdev_bugs.py b/tests/scripts/test_pkgdev_bugs.py
index e020ffd..641e5f0 100644
--- a/tests/scripts/test_pkgdev_bugs.py
+++ b/tests/scripts/test_pkgdev_bugs.py
@@ -68,7 +68,7 @@ class TestBugFiling:
         session = BugsSession()
         pkg = max(repo.itermatch(atom("=cat/u-0")))
         with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
-            bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ())
+            bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), (), None)
         assert len(session.calls) == 1
         call = session.calls[0]
         assert call["Bugzilla_api_key"] == "API"
@@ -83,7 +83,7 @@ class TestBugFiling:
         session = BugsSession()
         pkg = max(repo.itermatch(atom("=cat/z-0")))
         with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
-            bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ())
+            bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), (), None)
         assert len(session.calls) == 1
         call = session.calls[0]
         assert call["assigned_to"] == "maintainer-needed@gentoo.org"
@@ -99,7 +99,7 @@ class TestBugFiling:
         node = bugs.GraphNode(((pkgX, {"*"}), (pkgY, {"*"}), (pkgZ, {"*"})))
         node.edges.add(dep)
         with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
-            node.file_bug("API", frozenset(), ())
+            node.file_bug("API", frozenset(), (), None)
         assert len(session.calls) == 1
         call = session.calls[0]
         assert call["summary"] == "cat/x-0, cat/y-0, cat/z-0: stablereq"


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/
@ 2024-05-17 14:31 Arthur Zamarin
  0 siblings, 0 replies; 6+ messages in thread
From: Arthur Zamarin @ 2024-05-17 14:31 UTC (permalink / raw
  To: gentoo-commits

commit:     ecbda90d2d0dba4d65dd2f95e347cbc4152107e2
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri May 17 10:21:37 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri May 17 10:21:37 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=ecbda90d

mask: update removal line to match GLEP-84

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_mask.py | 2 +-
 tests/scripts/test_pkgdev_mask.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py
index 858c590..4ce2984 100644
--- a/src/pkgdev/scripts/pkgdev_mask.py
+++ b/src/pkgdev/scripts/pkgdev_mask.py
@@ -213,7 +213,7 @@ def get_comment(bugs, rites: int):
     tmp = tempfile.NamedTemporaryFile(mode="w")
     summary = []
     if rites:
-        summary.append(f"Removal: {datetime.now(timezone.utc) + timedelta(days=rites):%Y-%m-%d}.")
+        summary.append(f"Removal on {datetime.now(timezone.utc) + timedelta(days=rites):%Y-%m-%d}.")
     if bugs:
         # Bug(s) #A, #B, #C
         bug_list = ", ".join(f"#{b}" for b in bugs)

diff --git a/tests/scripts/test_pkgdev_mask.py b/tests/scripts/test_pkgdev_mask.py
index d723535..8366ced 100644
--- a/tests/scripts/test_pkgdev_mask.py
+++ b/tests/scripts/test_pkgdev_mask.py
@@ -294,7 +294,7 @@ class TestPkgdevMask:
                     f"""\
                         # First Last <first.last@email.com> ({today})
                         # mask comment
-                        # Removal: {removal}.
+                        # Removal on {removal}.
                         cat/pkg
                     """
                 )


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/
@ 2024-06-02 19:18 Arthur Zamarin
  0 siblings, 0 replies; 6+ messages in thread
From: Arthur Zamarin @ 2024-06-02 19:18 UTC (permalink / raw
  To: gentoo-commits

commit:     d37395418f44d5716a24d9cc84f8bf2d8bc084bb
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  2 19:18:05 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Jun  2 19:18:05 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=d3739541

mask: fix test & improve error messages

Resolves: https://github.com/pkgcore/pkgdev/issues/188
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_mask.py | 7 ++++++-
 tests/scripts/test_pkgdev_mask.py | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py
index 1d614a0..450c52c 100644
--- a/src/pkgdev/scripts/pkgdev_mask.py
+++ b/src/pkgdev/scripts/pkgdev_mask.py
@@ -101,7 +101,12 @@ def _mask_validate(parser, namespace):
     atoms = set()
     maintainers = set()
 
-    namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs)))
+    try:
+        namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs)))
+    except ValueError:
+        parser.error("argument -b/--bug: invalid integer value")
+    if min(namespace.bugs, default=1) < 1:
+        parser.error("argument -b/--bug: must be >= 1")
 
     if not namespace.rites and namespace.file_bug:
         mask.error("bug filing requires last rites")

diff --git a/tests/scripts/test_pkgdev_mask.py b/tests/scripts/test_pkgdev_mask.py
index 8366ced..63d1e53 100644
--- a/tests/scripts/test_pkgdev_mask.py
+++ b/tests/scripts/test_pkgdev_mask.py
@@ -337,6 +337,7 @@ class TestPkgdevMask:
             for bug_nums, expected in [
                 (["42"], "Bug #42."),
                 (["42", "43"], "Bugs #42, #43."),
+                (["42,43", "43"], "Bugs #42, #43."),
             ]:
                 args = []
                 for bug_num in bug_nums:
@@ -361,7 +362,7 @@ class TestPkgdevMask:
 
     def test_mask_bug_bad(self, capsys, tool):
         for arg, expected in [("-1", "must be >= 1"), ("foo", "invalid integer value")]:
-            with pytest.raises(SystemExit):
+            with pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
                 tool.parse_args(["mask", "--bug", arg])
             out, err = capsys.readouterr()
             assert err.strip() == f"pkgdev mask: error: argument -b/--bug: {expected}"


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-02 19:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 14:31 [gentoo-commits] proj/pkgcore/pkgdev:main commit in: tests/scripts/, src/pkgdev/scripts/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2024-06-02 19:18 Arthur Zamarin
2023-12-15 11:21 Arthur Zamarin
2023-08-24 18:14 Arthur Zamarin
2022-10-16 17:31 Arthur Zamarin
2022-10-14 19:36 Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox