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
Preserve %autochangelog in downstream spec file #1453
Conversation
Build succeeded.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! I have just one small suggestion and one note about the argument name.
packit/base_git.py
Outdated
""" | ||
update this specfile using provided specfile | ||
|
||
:param specfile: specfile to get changes from (we update self.specfile) | ||
:param version: version to set in self.specfile | ||
:param comment: new comment for the version in %changelog | ||
:param preserve_autochangelog: preserve the %autochangelog macro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit confused by the name of the argument at first. From the first usage (if at line 371
), it looks like has_autochangelog
but the second occurrence (if at line 384
) looks more like an add_new_changelog_entry
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, it seems confusing.
I tried to refactor this but line 370 made me roll back all the changes.
If I understand properly the code, in line 370 the downstream spec file content is overwritten by the original downstream spec file content. And you already told me a couple of good reasons for doing it.
In line 371, I am preserving the upstream %autochangelog macro (if any in the upstream spec file). In the case, as an example, that the original downstream spec file does not have one. I think this could happen, am I wrong?
In line 384, the version and the changelog are updated, if any. You are right, it seems I add a new empty changelog entry because I need to add a new version. I can not split changing the version and changing the changelog. Because any change to the version will be potentially overwritten by line 370 called when changing the changelog... thus the version must be updated only after that the changelog is updated...
I am not sure I answered your concerns. Please let me know If you have any suggestion on how to improve this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have anything about the implementation, but am just thinking if we can find a better name for that argument..;) But thanks for the detailed comment. Now I see why it's like this.
Maybe just more detailed parameter documentation will be enough. What about mentioning that when preserve_autochangelog
is set, we sync the macro to downstream and add no changelog entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sure
bcffd0c
to
b8d1ff6
Compare
Build succeeded.
|
b8d1ff6
to
a78aaac
Compare
Build failed.
|
packit/specfile.py
Outdated
for value in self.spec_content.section("%changelog"): | ||
if "%autochangelog" in value: | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about checking if there is any line that starts with %autochangelog
instead? The current implementation would return True
even for a comment line that contains %autochangelog
(which would be incorrect).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably go with the safer way:
%changelog
contains only%autochangelog
→True
%changelog
contains%autochangelog
and something else → raise an exception- otherwise →
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably go with the safer way:
* `%changelog` contains only `%autochangelog` → `True` * `%changelog` contains `%autochangelog` and something else → raise an exception * otherwise → `False`
I am not raising an exception because I thought that maybe it is too much to raise it if, as an example, there is a comment inside the section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good :)
a78aaac
to
2963e25
Compare
Build failed.
|
So I just noticed, that the issue asks for preserving
But the current PR is doing something else:
@jpopelka got confused the same way, as seen in his comment. Doing what this PR does, that is setting I think, we kinda got lost on this change 😄 But if this is the case, then we should clarify how such a functionality (that is: preserving My suggestion is that when On the other hand if |
2963e25
to
db9c62b
Compare
Build failed.
|
db9c62b
to
85cf291
Compare
I hope I got the right point of view, this time :) |
Build succeeded.
|
85cf291
to
9d70fbe
Compare
Build succeeded.
|
9d70fbe
to
f2479e7
Compare
Build succeeded.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small code-style suggestion, otherwise it looks really good.
And thanks for the tests!
131ed8a
to
b8d7e03
Compare
Build succeeded.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
recheck |
@majamassarini And now for the cause, it seems to me, that there is some older version of dependency that doesn't support |
I merged the PR manually few seconds before be able to see your comment. I hope it is not a problem. And thanks for explaining me how to trigger all the other builds. |
No problem, Zuul would merge it too, cause the tests ran in Zuul passed :) |
When the downstream spec file has the
%autochangelog
macro then preserve it in downstream.Do not preserve it if
sync_changelog
option is set.Fixes #1116