Skip to content

Commit eff9bba

Browse files
committed
commit: only call a variable updated when its value changed
The summaries generated from the sourced bash env intersected the names on the removed and added sides of the diff, without checking the value. Any change to a watched variable's declare line counted, gaining the export attribute or being requoted, so the summary announced an update to something the commit never touched. Compare the values instead. Resolves: #115 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent fc6c6fb commit eff9bba

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎NEWS.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ pkgdev 0.2.18 (unreleased)
3333
- commit: the mangler now adds the blank line after the ``EAPI=`` assignment
3434
(Arthur Zamarin, #127)
3535

36+
- commit: the generated summary no longer claims a variable was updated when
37+
only its ``declare`` line differs, as when it gains the export attribute
38+
while its value stays put (Arthur Zamarin, #115)
39+
3640
**pkgdev showkw:**
3741

3842
- showkw: drop the vendored copy of tabulate in favor of a dependency on

‎src/pkgdev/scripts/pkgdev_commit.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,9 @@ def modify(self):
586586
}
587587
targets = array_targets | string_targets
588588

589-
updated_vars = drop.keys() & add.keys()
589+
updated_vars = {
590+
name for name in drop.keys() & add.keys() if drop[name] != add[name]
591+
}
590592
if updated := sorted(watch_vars & updated_vars):
591593
summaries.add(f"update {', '.join(updated)}")
592594
elif (target := targets & updated_vars) and len(target) == 1:

‎tests/scripts/test_pkgdev_commit.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,16 @@ def test_generated_commit_summaries(self, capsys, repo, make_git_repo):
562562
)
563563
assert commit() == "cat/pkg: update DESCRIPTION, HOMEPAGE"
564564

565+
# a declare line differing only in its attributes is not an update:
566+
# exporting the var leaves its value alone
567+
repo.create_ebuild(
568+
"cat/pkg-7",
569+
description="another something",
570+
homepage="https://gentoo.org",
571+
data="export DESCRIPTION\n",
572+
)
573+
assert commit() == "cat/pkg: summary"
574+
565575
# update string_targets (USE_RUBY)
566576
os.mkdir(pjoin(repo.location, "profiles", "desc"))
567577
with open(pjoin(repo.path, "profiles", "desc", "ruby_targets.desc"), "w") as file:

0 commit comments

Comments
 (0)