prepare_spec: Try to preserve comments surrounding 'Group' #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit 89e01af ("prepare_spec: Improve the license and group
comments handling") fixed the code in order to preserve comments
referring to the License (and possibly to the Group) field. But it
didn't take into consideration those that only refer to the Group.
Moreover, it also broke those spec files which use comments after
the License or Group fields until the next RPM field. In order to
handle all these cases we need to tag where the License and Group
fields are located in the original spec file and try to preserve
the comments around them. This also means that in order for all
that to work, we need to make sure that License and Group fields
always appear after the Summary one in the original spec file. This
is necessary due to the way the code constructs the post-Summary
section of the spec file. The post-Summary section is being generated
as follows:
Summary:
License:
Group:
So in order to keep the comments where they should be we need to
make sure that the original spec file complies to this sequence.
And for that to happen, we need to break early in the process and
ask the user to reformat the file and run the script again. Hopefully,
most spec files already follow this pattern since, before this change,
the script always generated such a post-Summary section itself.
Fixes: #19
Fixes: 89e01af ("prepare_spec: Improve the license and group comments handling")
Signed-off-by: Markos Chandras mchandras@suse.de