Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare_spec: Try to preserve comments surrounding 'Group' #20

Closed
wants to merge 1 commit into from

Conversation

hwoarang
Copy link
Contributor

@hwoarang hwoarang commented Jan 5, 2017

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

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: openSUSE#19
Fixes: 89e01af ("prepare_spec: Improve the license and group comments handling")
Signed-off-by: Markos Chandras <mchandras@suse.de>
@coolo
Copy link
Member

coolo commented Jan 26, 2021

I looked into it and nothing against your effort, but IMO it just shows how overdue a little rework on the logic is.

I was hoping for the last couple of years that spec-cleaner finally deprecates this tool, but they never found a large enough fan base :(

So I'm working on a refactoring - taking "your" bug into account.

@coolo coolo closed this Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

comment moved wrongly
2 participants