Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-specfile for openSUSE:Factory 
checked in at 2023-05-30 22:03:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-specfile (Old)
 and      /work/SRC/openSUSE:Factory/.python-specfile.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-specfile"

Tue May 30 22:03:07 2023 rev:12 rq:1089806 version:0.18.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-specfile/python-specfile.changes  
2023-05-12 20:40:00.134762606 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-specfile.new.1533/python-specfile.changes    
    2023-05-30 22:03:21.047331514 +0200
@@ -1,0 +2,6 @@
+Mon May 29 09:50:26 UTC 2023 - David Anes <david.a...@suse.com>
+
+- Update to version 0.18.0: 
+  * Specfile library now handles multiple %changelog sections. (#230)
+
+-------------------------------------------------------------------

Old:
----
  specfile-0.17.0.tar.gz

New:
----
  specfile-0.18.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-specfile.spec ++++++
--- /var/tmp/diff_new_pack.DhF9Bt/_old  2023-05-30 22:03:21.579334650 +0200
+++ /var/tmp/diff_new_pack.DhF9Bt/_new  2023-05-30 22:03:21.583334673 +0200
@@ -18,7 +18,7 @@
 
 %define skip_python38 1
 Name:           python-specfile
-Version:        0.17.0
+Version:        0.18.0
 Release:        0
 Summary:        A library for parsing and manipulating RPM spec files
 License:        MIT

++++++ specfile-0.17.0.tar.gz -> specfile-0.18.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/.pre-commit-config.yaml 
new/specfile-0.18.0/.pre-commit-config.yaml
--- old/specfile-0.17.0/.pre-commit-config.yaml 2023-05-11 11:43:56.000000000 
+0200
+++ new/specfile-0.18.0/.pre-commit-config.yaml 2023-05-26 11:50:44.000000000 
+0200
@@ -4,15 +4,15 @@
 
 repos:
   - repo: https://github.com/asottile/pyupgrade
-    rev: v3.3.1
+    rev: v3.4.0
     hooks:
       - id: pyupgrade
   - repo: https://github.com/psf/black
-    rev: 23.1.0
+    rev: 23.3.0
     hooks:
       - id: black
   - repo: https://github.com/pre-commit/mirrors-prettier
-    rev: v3.0.0-alpha.6
+    rev: v3.0.0-alpha.9-for-vscode
     hooks:
       - id: prettier
   - repo: https://github.com/pre-commit/pre-commit-hooks
@@ -44,14 +44,14 @@
       - id: isort
         args: [--profile, black]
   - repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v1.1.1
+    rev: v1.3.0
     hooks:
       - id: mypy
         args: [--show-error-codes, --ignore-missing-imports]
         additional_dependencies:
           [types-pkg_resources, types-requests, types-python-dateutil]
   - repo: https://github.com/packit/pre-commit-hooks
-    rev: v1.0.0
+    rev: v1.2.0
     hooks:
       - id: check-rebase
         args:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/CHANGELOG.md 
new/specfile-0.18.0/CHANGELOG.md
--- old/specfile-0.17.0/CHANGELOG.md    2023-05-11 11:43:56.000000000 +0200
+++ new/specfile-0.18.0/CHANGELOG.md    2023-05-26 11:50:44.000000000 +0200
@@ -1,3 +1,7 @@
+# 0.18.0
+
+- Specfile library now handles multiple `%changelog` sections. (#230)
+
 # 0.17.0
 
 - Added a new `guess_packager()` function that uses similar heuristics as 
`rpmdev-packager`, meaning that the `Specfile.add_changelog_entry()` method no 
longer requires `rpmdev-packager` to guess the changelog entry author. (#220)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/PKG-INFO new/specfile-0.18.0/PKG-INFO
--- old/specfile-0.17.0/PKG-INFO        2023-05-11 11:44:06.806230300 +0200
+++ new/specfile-0.18.0/PKG-INFO        2023-05-26 11:50:53.421457300 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: specfile
-Version: 0.17.0
+Version: 0.18.0
 Summary: A library for parsing and manipulating RPM spec files.
 Home-page: https://github.com/packit/specfile
 Author: Red Hat
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/fedora/python-specfile.spec 
new/specfile-0.18.0/fedora/python-specfile.spec
--- old/specfile-0.17.0/fedora/python-specfile.spec     2023-05-11 
11:43:56.000000000 +0200
+++ new/specfile-0.18.0/fedora/python-specfile.spec     2023-05-26 
11:50:44.000000000 +0200
@@ -13,7 +13,7 @@
 
 
 Name:           python-specfile
-Version:        0.17.0
+Version:        0.18.0
 Release:        1%{?dist}
 
 Summary:        A library for parsing and manipulating RPM spec files
@@ -71,6 +71,9 @@
 
 
 %changelog
+* Fri May 26 2023 Packit Team <he...@packit.dev> - 0.18.0-1
+- New upstream release 0.18.0
+
 * Thu May 11 2023 Packit Team <he...@packit.dev> - 0.17.0-1
 - New upstream release 0.17.0
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/specfile/specfile.py 
new/specfile-0.18.0/specfile/specfile.py
--- old/specfile-0.17.0/specfile/specfile.py    2023-05-11 11:43:56.000000000 
+0200
+++ new/specfile-0.18.0/specfile/specfile.py    2023-05-26 11:50:44.000000000 
+0200
@@ -264,17 +264,26 @@
                 section.data = tags.get_raw_section_data()
 
     @ContextManager
-    def changelog(self) -> Generator[Optional[Changelog], None, None]:
+    def changelog(
+        self, section: Optional[Section] = None
+    ) -> Generator[Optional[Changelog], None, None]:
         """
         Context manager for accessing changelog.
 
+        Args:
+            section: Optional `Section` instance to be processed. If not set, 
the first
+              %changelog section (if any) will be processed.
+
         Yields:
             Spec file changelog as `Changelog` object or None if there is no 
%changelog section.
         """
         with self.sections() as sections:
-            try:
-                section = sections.changelog
-            except AttributeError:
+            if section is None:
+                try:
+                    section = sections.changelog
+                except AttributeError:
+                    section = None
+            if section is None:
                 yield None
             else:
                 changelog = Changelog.parse(section)
@@ -388,24 +397,39 @@
                 return True
         return False
 
+    @staticmethod
+    def contains_autochangelog(section: Section) -> bool:
+        """
+        Determines if the specified section contains the %autochangelog macro.
+
+        Args:
+            section: Section to examine.
+
+        Returns:
+            True if the section contains %autochangelog, False otherwise.
+        """
+        for line in section:
+            if line.lstrip().startswith("#"):
+                # skip comments
+                continue
+            for node in ValueParser.flatten(ValueParser.parse(line)):
+                if (
+                    isinstance(node, (MacroSubstitution, 
EnclosedMacroSubstitution))
+                    and node.name == "autochangelog"
+                ):
+                    return True
+        return False
+
     @property
     def has_autochangelog(self) -> bool:
         """Whether the spec file uses %autochangelog."""
         with self.sections() as sections:
-            try:
-                changelog = sections.changelog
-            except AttributeError:
-                return False
-            for line in changelog:
-                if line.lstrip().startswith("#"):
-                    # skip comments
+            # there could be multiple changelog sections, consider all of them
+            for section in sections:
+                if not section.normalized_id == "changelog":
                     continue
-                for node in ValueParser.flatten(ValueParser.parse(line)):
-                    if (
-                        isinstance(node, (MacroSubstitution, 
EnclosedMacroSubstitution))
-                        and node.name == "autochangelog"
-                    ):
-                        return True
+                if self.contains_autochangelog(section):
+                    return True
             return False
 
     def add_changelog_entry(
@@ -434,45 +458,53 @@
               determines the appropriate value based on the specfile's current
               %{epoch}, %{version}, and %{release} values.
         """
-        if self.has_autochangelog:
-            return
-        if evr is None:
-            evr = "%{?epoch:%{epoch}:}%{version}-%{release}"
-        with self.changelog() as changelog:
-            if changelog is None:
-                return
-            evr = self.expand(evr, extra_macros=[("dist", "")])
-            if isinstance(entry, str):
-                entry = [entry]
-            if timestamp is None:
-                # honor the timestamp format, but default to date-only
-                if changelog and changelog[-1].extended_timestamp:
-                    timestamp = datetime.datetime.now().astimezone()
-                else:
-                    timestamp = 
datetime.datetime.now(datetime.timezone.utc).date()
-            if author is None:
-                author = guess_packager()
-                if not author:
-                    raise SpecfileException("Failed to auto-detect author")
-            elif email is not None:
-                author += f" <{email}>"
-            if changelog:
-                # try to preserve padding of day of month
-                padding = max(
-                    (e.day_of_month_padding for e in reversed(changelog)), 
key=len
-                )
-            else:
-                padding = "0"
-            changelog.append(
-                ChangelogEntry.assemble(
-                    timestamp,
-                    author,
-                    entry,
-                    evr,
-                    day_of_month_padding=padding,
-                    append_newline=bool(changelog),
-                )
-            )
+        with self.sections() as sections:
+            # there could be multiple changelog sections, update all of them
+            for section in sections:
+                if not section.normalized_id == "changelog":
+                    continue
+                if self.contains_autochangelog(section):
+                    continue
+                if evr is None:
+                    evr = "%{?epoch:%{epoch}:}%{version}-%{release}"
+                with self.changelog(section) as changelog:
+                    if changelog is None:
+                        return
+                    evr = self.expand(evr, extra_macros=[("dist", "")])
+                    if isinstance(entry, str):
+                        entry = [entry]
+                    if timestamp is None:
+                        # honor the timestamp format, but default to date-only
+                        if changelog and changelog[-1].extended_timestamp:
+                            timestamp = datetime.datetime.now().astimezone()
+                        else:
+                            timestamp = datetime.datetime.now(
+                                datetime.timezone.utc
+                            ).date()
+                    if author is None:
+                        author = guess_packager()
+                        if not author:
+                            raise SpecfileException("Failed to auto-detect 
author")
+                    elif email is not None:
+                        author += f" <{email}>"
+                    if changelog:
+                        # try to preserve padding of day of month
+                        padding = max(
+                            (e.day_of_month_padding for e in 
reversed(changelog)),
+                            key=len,
+                        )
+                    else:
+                        padding = "0"
+                    changelog.append(
+                        ChangelogEntry.assemble(
+                            timestamp,
+                            author,
+                            entry,
+                            evr,
+                            day_of_month_padding=padding,
+                            append_newline=bool(changelog),
+                        )
+                    )
 
     def _tag(name: str, doc: str) -> property:  # type: ignore[misc]
         """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/specfile.egg-info/PKG-INFO 
new/specfile-0.18.0/specfile.egg-info/PKG-INFO
--- old/specfile-0.17.0/specfile.egg-info/PKG-INFO      2023-05-11 
11:44:06.000000000 +0200
+++ new/specfile-0.18.0/specfile.egg-info/PKG-INFO      2023-05-26 
11:50:53.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: specfile
-Version: 0.17.0
+Version: 0.18.0
 Summary: A library for parsing and manipulating RPM spec files.
 Home-page: https://github.com/packit/specfile
 Author: Red Hat
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/specfile.egg-info/SOURCES.txt 
new/specfile-0.18.0/specfile.egg-info/SOURCES.txt
--- old/specfile-0.17.0/specfile.egg-info/SOURCES.txt   2023-05-11 
11:44:06.000000000 +0200
+++ new/specfile-0.18.0/specfile.egg-info/SOURCES.txt   2023-05-26 
11:50:53.000000000 +0200
@@ -88,6 +88,7 @@
 tests/data/spec_commented_patches/patch6.patch
 tests/data/spec_commented_patches/test-0.1.tar.xz
 tests/data/spec_commented_patches/test.spec
+tests/data/spec_conditionalized_changelog/test.spec
 tests/data/spec_includes/description1.inc
 tests/data/spec_includes/description2.inc
 tests/data/spec_includes/macros1.inc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/tests/constants.py 
new/specfile-0.18.0/tests/constants.py
--- old/specfile-0.17.0/tests/constants.py      2023-05-11 11:43:56.000000000 
+0200
+++ new/specfile-0.18.0/tests/constants.py      2023-05-26 11:50:44.000000000 
+0200
@@ -16,5 +16,6 @@
 SPEC_MULTIPLE_SOURCES = DATA_DIR / "spec_multiple_sources"
 SPEC_COMMENTED_PATCHES = DATA_DIR / "spec_commented_patches"
 SPEC_SHELL_EXPANSIONS = DATA_DIR / "spec_shell_expansions"
+SPEC_CONDITIONALIZED_CHANGELOG = DATA_DIR / "spec_conditionalized_changelog"
 
 SPECFILE = "test.spec"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/specfile-0.17.0/tests/data/spec_conditionalized_changelog/test.spec 
new/specfile-0.18.0/tests/data/spec_conditionalized_changelog/test.spec
--- old/specfile-0.17.0/tests/data/spec_conditionalized_changelog/test.spec     
1970-01-01 01:00:00.000000000 +0100
+++ new/specfile-0.18.0/tests/data/spec_conditionalized_changelog/test.spec     
2023-05-26 11:50:44.000000000 +0200
@@ -0,0 +1,20 @@
+Name:           test
+Version:        0.1
+Release:        %autorelease
+Summary:        Test package
+
+License:        MIT
+
+
+%description
+Test package
+
+
+%if 0%{?fedora}
+%changelog
+%autochangelog
+%else
+%changelog
+* Mon May 22 2023 Nikola Forró <nfo...@redhat.com>
+- Initial package
+%endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/tests/integration/conftest.py 
new/specfile-0.18.0/tests/integration/conftest.py
--- old/specfile-0.17.0/tests/integration/conftest.py   2023-05-11 
11:43:56.000000000 +0200
+++ new/specfile-0.18.0/tests/integration/conftest.py   2023-05-26 
11:50:44.000000000 +0200
@@ -9,6 +9,7 @@
     SPEC_AUTOPATCH,
     SPEC_AUTOSETUP,
     SPEC_COMMENTED_PATCHES,
+    SPEC_CONDITIONALIZED_CHANGELOG,
     SPEC_INCLUDES,
     SPEC_MACROS,
     SPEC_MINIMAL,
@@ -96,3 +97,10 @@
     destination = tmp_path / "spec_shell_expansions"
     shutil.copytree(SPEC_SHELL_EXPANSIONS, destination)
     return destination / SPECFILE
+
+
+@pytest.fixture(scope="function")
+def spec_conditionalized_changelog(tmp_path):
+    specfile_path = tmp_path / SPECFILE
+    shutil.copyfile(SPEC_CONDITIONALIZED_CHANGELOG / SPECFILE, specfile_path)
+    return specfile_path
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/specfile-0.17.0/tests/integration/test_specfile.py 
new/specfile-0.18.0/tests/integration/test_specfile.py
--- old/specfile-0.17.0/tests/integration/test_specfile.py      2023-05-11 
11:43:56.000000000 +0200
+++ new/specfile-0.18.0/tests/integration/test_specfile.py      2023-05-26 
11:50:44.000000000 +0200
@@ -325,7 +325,7 @@
 @pytest.mark.skipif(
     rpm.__version__ < "4.16", reason="%autochangelog requires rpm 4.16 or 
higher"
 )
-def test_autochangelog(spec_rpmautospec):
+def test_autochangelog(spec_rpmautospec, spec_conditionalized_changelog):
     spec = Specfile(spec_rpmautospec)
     assert spec.has_autochangelog
     with spec.changelog() as changelog:
@@ -335,6 +335,17 @@
     spec.add_changelog_entry("test")
     with spec.sections() as sections:
         assert sections.changelog == changelog
+    spec = Specfile(spec_conditionalized_changelog)
+    assert spec.has_autochangelog
+    with spec.sections() as sections:
+        changelog = sections.changelog.copy()
+    spec.add_changelog_entry("test")
+    with spec.sections() as sections:
+        changelogs = [s for s in sections if s.normalized_name == "changelog"]
+    assert len(changelogs) == 2
+    assert changelogs[0] == changelog
+    with spec.changelog(changelogs[1]) as changelog:
+        assert changelog[-1].content == ["test"]
 
 
 def test_update_tag(spec_macros):

Reply via email to