Skip to content

Commit 14e9520

Browse files
committed
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@gentoo.org> Resolves: #116 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 4085146 commit 14e9520

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/pkgdev/scripts/pkgdev_commit.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,19 @@ def rename(self):
397397
@change('M')
398398
def modify(self):
399399
"""Generate summaries for modify actions."""
400-
if len(self.changes) == 1:
401-
atom = next(iter(self.changes))
400+
summaries = set()
401+
for atom in self.changes:
402402
pkgs = self.repo.match(atom)
403403
self.old_repo.add_pkgs(pkgs)
404404
try:
405405
old_pkg = self.old_repo.match(atom)[0]
406406
new_pkg = pkgs[0]
407407
except IndexError: # pragma: no cover
408408
# broken ebuild should be caught during manifesting or scanning
409-
return
409+
continue
410410

411411
if old_pkg.eapi in new_pkg.eapi.inherits[1:]:
412-
return f'update EAPI {old_pkg.eapi} -> {new_pkg.eapi}'
412+
summaries.add(f'update EAPI {old_pkg.eapi} -> {new_pkg.eapi}')
413413
elif new_pkg.keywords != old_pkg.keywords:
414414
repo_stable = set(self.repo.config.arches_desc['stable'])
415415
new_keywords = set(new_pkg.keywords)
@@ -434,8 +434,9 @@ def modify(self):
434434
msg = f"{action} for {', '.join(sorted(removed))}"
435435

436436
if len(msg) <= 50:
437-
return msg
438-
return action
437+
summaries.add(msg)
438+
else:
439+
summaries.add(action)
439440
else:
440441
# use sourced bash env diffs to determine summaries
441442
old_env = old_pkg.environment.data.splitlines()
@@ -458,10 +459,10 @@ def modify(self):
458459

459460
updated_vars = drop.keys() & add.keys()
460461
if updated := sorted(watch_vars & updated_vars):
461-
return f"update {', '.join(updated)}"
462+
summaries.add(f"update {', '.join(updated)}")
462463
elif (target := targets & updated_vars) and len(target) == 1:
463464
target = next(iter(target))
464-
py_re = lambda x: re.sub(r'^python(\d+)_(\d+)$', r'py\1.\2', x)
465+
py_re = partial(re.sub, r'^python(\d+)_(\d+)$', r'py\1.\2')
465466
use_expand = {py_re(use[len(target)+2:])
466467
for use, _ in self.repo.use_expand_desc[use_expand_mapping[target]]}
467468
if target in array_targets:
@@ -480,9 +481,11 @@ def modify(self):
480481
msg.append(f"disable {', '.join(sorted(dropped))}")
481482
msg = ' and '.join(msg)
482483
if len(msg) <= 50:
483-
return msg
484+
summaries.add(msg)
484485
else:
485-
return f'update {target} support'
486+
summaries.add(f'update {target} support')
487+
if len(summaries) == 1:
488+
return next(iter(summaries))
486489

487490

488491
class GitChanges(UserDict):

tests/scripts/test_pkgdev_commit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def commit():
448448

449449
# multiple additions
450450
repo.create_ebuild('cat/pkg-2')
451-
repo.create_ebuild('cat/pkg-3')
451+
repo.create_ebuild('cat/pkg-3', eapi=6)
452452
repo.create_ebuild('cat/pkg-4', eapi=6)
453453
assert commit() == 'cat/pkg: add 2, 3, 4'
454454

@@ -464,9 +464,10 @@ def commit():
464464
)
465465
assert commit() == 'cat/pkg: add 5, drop 4'
466466

467-
# bump EAPI
467+
# bump EAPI for multiple versions, same summary
468468
repo.create_ebuild('cat/pkg-6', eapi='6')
469469
git_repo.add_all('cat/pkg-6')
470+
repo.create_ebuild('cat/pkg-3', eapi='7')
470471
repo.create_ebuild('cat/pkg-6', eapi='7')
471472
assert commit() == 'cat/pkg: update EAPI 6 -> 7'
472473

0 commit comments

Comments
 (0)