commit: 14e95205e08453d9dce26cce803f1a877191961a Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Fri Jan 13 21:30:58 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Fri Jan 13 21:30:58 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=14e95205
commit: use same summary for multiple ebuilds If 2 or more ebuilds are being modified, and same summary is generated for both of them, use it for both ebuilds instead of giving up. Reported-by: Joonas Niilola <juippis <AT> gentoo.org> Resolves: https://github.com/pkgcore/pkgdev/issues/116 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgdev/scripts/pkgdev_commit.py | 23 +++++++++++++---------- tests/scripts/test_pkgdev_commit.py | 5 +++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py index 03dfdb6..1373b35 100644 --- a/src/pkgdev/scripts/pkgdev_commit.py +++ b/src/pkgdev/scripts/pkgdev_commit.py @@ -397,8 +397,8 @@ class PkgSummary(ChangeSummary): @change('M') def modify(self): """Generate summaries for modify actions.""" - if len(self.changes) == 1: - atom = next(iter(self.changes)) + summaries = set() + for atom in self.changes: pkgs = self.repo.match(atom) self.old_repo.add_pkgs(pkgs) try: @@ -406,10 +406,10 @@ class PkgSummary(ChangeSummary): new_pkg = pkgs[0] except IndexError: # pragma: no cover # broken ebuild should be caught during manifesting or scanning - return + continue if old_pkg.eapi in new_pkg.eapi.inherits[1:]: - return f'update EAPI {old_pkg.eapi} -> {new_pkg.eapi}' + summaries.add(f'update EAPI {old_pkg.eapi} -> {new_pkg.eapi}') elif new_pkg.keywords != old_pkg.keywords: repo_stable = set(self.repo.config.arches_desc['stable']) new_keywords = set(new_pkg.keywords) @@ -434,8 +434,9 @@ class PkgSummary(ChangeSummary): msg = f"{action} for {', '.join(sorted(removed))}" if len(msg) <= 50: - return msg - return action + summaries.add(msg) + else: + summaries.add(action) else: # use sourced bash env diffs to determine summaries old_env = old_pkg.environment.data.splitlines() @@ -458,10 +459,10 @@ class PkgSummary(ChangeSummary): updated_vars = drop.keys() & add.keys() if updated := sorted(watch_vars & updated_vars): - return f"update {', '.join(updated)}" + summaries.add(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) + py_re = partial(re.sub, r'^python(\d+)_(\d+)$', r'py\1.\2') 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: @@ -480,9 +481,11 @@ class PkgSummary(ChangeSummary): msg.append(f"disable {', '.join(sorted(dropped))}") msg = ' and '.join(msg) if len(msg) <= 50: - return msg + summaries.add(msg) else: - return f'update {target} support' + summaries.add(f'update {target} support') + if len(summaries) == 1: + return next(iter(summaries)) class GitChanges(UserDict): diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py index 7b2eb61..7ca9c0d 100644 --- a/tests/scripts/test_pkgdev_commit.py +++ b/tests/scripts/test_pkgdev_commit.py @@ -448,7 +448,7 @@ class TestPkgdevCommit: # multiple additions repo.create_ebuild('cat/pkg-2') - repo.create_ebuild('cat/pkg-3') + repo.create_ebuild('cat/pkg-3', eapi=6) repo.create_ebuild('cat/pkg-4', eapi=6) assert commit() == 'cat/pkg: add 2, 3, 4' @@ -464,9 +464,10 @@ class TestPkgdevCommit: ) assert commit() == 'cat/pkg: add 5, drop 4' - # bump EAPI + # bump EAPI for multiple versions, same summary repo.create_ebuild('cat/pkg-6', eapi='6') git_repo.add_all('cat/pkg-6') + repo.create_ebuild('cat/pkg-3', eapi='7') repo.create_ebuild('cat/pkg-6', eapi='7') assert commit() == 'cat/pkg: update EAPI 6 -> 7'
