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

Implement Sections.get_or_create() #441

Merged
merged 1 commit into from
Dec 13, 2024
Merged

Conversation

nforro
Copy link
Member

@nforro nforro commented Dec 12, 2024

Fixes #404.

RELEASE NOTES BEGIN

There is a new convenience method Sections.get_or_create() that allows you to manipulate a section without checking if it exists first. If a section doesn't exist, it will be appended to the end. For example, this will work properly even on spec files without %changelog:

with spec.sections() as sections:
    changelog = sections.get_or_create("changelog")
    changelog[:] = ["%autochangelog"]

RELEASE NOTES END

Copy link
Contributor

Build succeeded.
https://softwarefactory-project.io/zuul/t/packit-service/buildset/e6d4a773ab6844e399a4023c6e7ae82e

✔️ pre-commit SUCCESS in 1m 55s
✔️ specfile-tests-rpm-deps SUCCESS in 1m 02s
✔️ specfile-tests-pip-deps SUCCESS in 1m 01s

Copy link
Member

@lachmanfrantisek lachmanfrantisek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems handy. Thanks for the example in the release notes.

@nforro nforro added the mergeit Zuul, merge it! label Dec 13, 2024
Copy link
Contributor

Build succeeded (gate pipeline).
https://softwarefactory-project.io/zuul/t/packit-service/buildset/fc79606bbb7d4d28b9614770736f4ae2

✔️ pre-commit SUCCESS in 1m 49s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit b5b95e9 into main Dec 13, 2024
36 of 37 checks passed
@nforro nforro deleted the sections branch December 13, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mergeit Zuul, merge it!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'Sections' object has no attribute 'changelog'
2 participants