packit / specfile

A library for parsing and manipulating RPM spec files
MIT License
25 stars 15 forks source link

add_changelog_entry misplaces extra newlines #139

Closed pcahyna closed 1 year ago

pcahyna commented 1 year ago

Empty lines in %changelog entries are moved to the end of the entry. See this reproducer

from specfile import Specfile
specfile=Specfile('linux-system-roles.spec')
specfile.add_changelog_entry('bump')
specfile.save()

Result:

diff --git a/linux-system-roles.spec b/linux-system-roles.spec
index fbe915a..2cb20e1 100644
--- a/linux-system-roles.spec
+++ b/linux-system-roles.spec
@@ -757,6 +757,9 @@ find %{buildroot}%{ansible_roles_dir} -mindepth 1 -maxdepth 1 | \
 %endif

 %changelog
+* Mon Nov 21 2022 Pavel Cahyna <...> - 1.22.0-4
+bump
+
 * Tue Nov 08 2022 Sergei Petrosian <...> - 1.22.0-4
 - Fix issue with package update introduce with changing symlink to directory
   Resolves:rhbz#2141152
@@ -897,42 +900,42 @@ find %{buildroot}%{ansible_roles_dir} -mindepth 1 -maxdepth 1 | \
 - storage - fix coverity scan issue in blivet.py
   Resolves: rhbz#2066876 (8.7.0)
   Resolves: rhbz#2072745 (9.1.0)
-
 - logging - fix gather_facts/set_vars issue
   Resolves: rhbz#2079008 (8.7.0)
   Resolves: rhbz#2078989 (9.1.0)
-
 - ha_cluster - Move tasks that set up CI environment to roles tasks/ dir
   Resolves: rhbz#2093500 (8.7.0)
   Resolves: rhbz#2093438 (9.1.0)
-
 - sshd - fix tests issue with rhel9 hosts

+
+
+
 * Mon Jun 06 2022 Rich Megginson <...> - 1.20.0-1
 - storage - support for creating and managing LVM thin pools/LVs
   Resolves: rhbz#2066876 (8.7.0)
   Resolves: rhbz#2072745 (9.1.0)
-
 - firewall - Update Ansible syntax in Firewall system role README.md file examples
   Resolves: rhbz#2081839 (8.7.0)
   Resolves: rhbz#2094096 (9.1.0)
-
 - storage role raid_level "striped" is not supported
   Resolves: rhbz#2083426 (8.7.0)
   Resolves: rhbz#2083410 (9.1.0)
-
 - network: the controller device is not completely cleaned up in the bond tests.
   Resolves: rhbz#2089868 (8.7.0)
   Resolves: rhbz#2089872 (9.1.0)
-
 - firewall - state no longer required for masquerade and ICMP block inversion
   Resolves: rhbz#2093437 (8.7.0)
   Resolves: rhbz#2093423 (9.1.0)
-
 - ha_cluster - Move tasks that set up CI environment to roles tasks/ dir
   Resolves: rhbz#2093500 (8.7.0)
   Resolves: rhbz#2093438 (9.1.0)

+
+
+
+
+
 * Wed Jun 01 2022 Sergei Petrosian <...> - 1.19.0-2
 - Update ansible.posix, community.general

@@ -950,113 +953,113 @@ find %{buildroot}%{ansible_roles_dir} -mindepth 1 -maxdepth 1 | \
 - sshd - sshd system role should not assume that RHEL 9 /etc/ssh/sshd_config has "Include > /etc/ssh/sshd_config.d/*.conf"
   Resolves: rhbz#2086934 (8.7.0)
   Resolves: rhbz#2052081 (9.1.0)
-
 - sshd - sshd system role should be able to optionally manage /etc/ssh/sshd_config on RHEL 9
   Resolves: rhbz#2086935 (8.7.0)
   Resolves: rhbz#2052086 (9.1.0)
-
 - storage - storage role cannot set mount_options for volumes
   Resolves: rhbz#2083378 (8.7.0)
   Resolves: rhbz#2083376 (9.1.0)

+
+
 * Mon May 02 2022 Rich Megginson <...> - 1.18.0-1
 - metrics - [RFE] add an option to the metrics role to enable postfix metric collection
   Resolves: rhbz#2043009 (8.7.0)
   Resolves: rhbz#2043010 (9.1.0)
-
 - firewall - [Improvement] Allow System Role to reset to default Firewalld Settings
   Resolves: rhbz#2043009 (8.7.0)
   Resolves: rhbz#2061511 (9.1.0)

+
 * Mon Apr 25 2022 Rich Megginson <...> - 1.17.0-1
 - All roles should support running with gather_facts: false
   Resolves: rhbz#2079008 (8.7.0)
   Resolves: rhbz#2078989 (9.1.0)
-
 - firewall - Firewall system role Ansible deprecation warning related to "include"
   Resolves: rhbz#2078650 (8.7.0)
   Resolves: rhbz#2061511 (9.1.0)
-
 - ha_cluster - ha_cluster - support advanced corosync configuration
   Resolves: rhbz#2065339 (8.7.0)
   Resolves: rhbz#2065337 (9.1.0)
-
 - ha_cluster - ha_cluster - support SBD fencing
   Resolves: rhbz#2066868 (8.7.0)
   Resolves: rhbz#2079626 (9.1.0)
-
 - ha_cluster - ha_cluster - add support for configuring bundle resources
   Resolves: rhbz#2073518 (8.7.0)
   Resolves: rhbz#2073519 (9.1.0)
-
 - kernel_settings - kernel_settings error configobj not found on RHEL 8.6 managed hosts
   Resolves: rhbz#2060378 (8.7.0)
   Resolves: rhbz#2060525 (9.1.0)
-
 - logging - logging tests fail during cleanup if no cloud-init on system
   Resolves: rhbz#2058807 (8.7.0)
   Resolves: rhbz#2058799 (9.1.0)
-
 - logging - Logging - RFE - support template, severity and facility options
   Resolves: rhbz#2075116 (8.7.0)
   Resolves: rhbz#2075119 (9.1.0)
-
 - metrics - Metrics role, with "metrics_from_mssql" option does not configure /var/lib/pcp/pmdas/mssql/mssql.conf on first run
   Resolves: rhbz#2060377 (8.7.0)
   Resolves: rhbz#2060523 (9.1.0)
-
 - metrics - metrics - consistently use ansible_managed in configuration files managed by role
   Resolves: rhbz#2065215 (8.7.0)
   Resolves: rhbz#2065392 (9.1.0)
-
 - metrics - [RFE] add an option to the metrics role to enable postfix metric collection
   Resolves: rhbz#2079114 (8.7.0)
   Resolves: rhbz#2051737 (9.1.0)
-
 - nbde_client - NBDE client system role does not support servers with static IP addresses
   Resolves: rhbz#2071011 (8.7.0)
   Resolves: rhbz#2070462 (9.1.0)
-
 - network - [RFE] Extend rhel-system-roles.network feature set to support routing rules
   Resolves: rhbz#1996731 (8.7.0)
   Resolves: rhbz#2079622 (9.1.0)
-
 - network - bond: fix typo in supporting the infiniband ports in active-backup mode
   Resolves: rhbz#2064067 (8.7.0)
   Resolves: rhbz#2065394 (9.1.0)
-
 - network - pytest failed when running with nm providers in the rhel-8.5 beaker machine
   Resolves: rhbz#2065217 (8.7.0)
   Resolves: rhbz#2066911 (9.1.0)
-
 - network - network - consistently use ansible_managed in configuration files managed by role
   Resolves: rhbz#2065670 (8.7.0)
   Resolves: rhbz#2065382 (9.1.0)
-
 - postfix - postfix - consistently use ansible_managed in configuration files managed by role
   Resolves: rhbz#2065216 (8.7.0)
   Resolves: rhbz#2065393 (9.1.0)
-
 - postfix - Postfix RHEL System Role should provide the ability to replace config and reset configuration back to default
   Resolves: rhbz#2065218 (8.7.0)
   Resolves: rhbz#2065383 (9.1.0)
-
 - sshd - FIPS mode detection in SSHD role is wrong
   Resolves: rhbz#2075338 (8.7.0)
   Resolves: rhbz#2073605 (9.1.0)
-
 - storage - RFE storage Less verbosity by default
   Resolves: rhbz#2056480 (8.7.0)
   Resolves: rhbz#2079627 (9.1.0)
-
 - timesync - timesync: basic-smoke test failure in timesync/tests_ntp.yml
   Resolves: rhbz#2060379 (8.7.0)
   Resolves: rhbz#2060524 (9.1.0)
-
 - tlog - Tlog role - Enabling session recording configuration does not work due to RHEL9 SSSD files provider default
   Resolves: rhbz#2072749 (8.7.0)
   Resolves: rhbz#2071804 (9.1.0)

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 * Thu Apr 07 2022 Rich Megginson <...> - 1.16.3-1
 - tlog - Enabling session recording configuration does not work due to RHEL9 SSSD files provider default
   Resolves rhbz#2072749 (EL8)

linux-system-roles.spec can be found here https://src.fedoraproject.org/rpms/linux-system-roles and an example diff with this problem created by Packit can be seen here: https://src.fedoraproject.org/rpms/linux-system-roles/pull-request/98#request_diff

nforro commented 1 year ago

Thanks for the report. I'll try to fix this ASAP.