-
Notifications
You must be signed in to change notification settings - Fork 20
Add support for openSUSE style detached changelogs #444
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
Merged
softwarefactory-project-zuul
merged 1 commit into
packit:main
from
dcermak:suse-style-detached-changelogs
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,16 @@ | |
|
|
||
| import copy | ||
| import datetime | ||
| from typing import Optional | ||
| from typing import List, Optional, Union | ||
|
|
||
| import pytest | ||
|
|
||
| from specfile.changelog import Changelog, ChangelogEntry | ||
| from specfile.changelog import ( | ||
| _OPENSUSE_CHANGELOG_SEPARATOR, | ||
| Changelog, | ||
| ChangelogEntry, | ||
| ChangelogStyle, | ||
| ) | ||
| from specfile.sections import Section | ||
| from specfile.utils import EVR | ||
|
|
||
|
|
@@ -240,6 +245,140 @@ def test_parse(): | |
| ] | ||
| assert not changelog[6].extended_timestamp | ||
|
|
||
| assert all( | ||
| changelog_entry.style == ChangelogStyle.standard | ||
| for changelog_entry in changelog | ||
| ) | ||
|
|
||
|
|
||
| def test_suse_style_changelog_parse(): | ||
| changelog = Changelog.parse( | ||
| Section( | ||
| "changelog", | ||
| data=[ | ||
| "-------------------------------------------------------------------", | ||
| ( | ||
| hdr1 := "Tue Dec 17 14:21:37 UTC 2024 - " | ||
| + (dc := "Dan Čermák <[email protected]>") | ||
| ), | ||
| "", | ||
| (content1 := "- First version"), | ||
| "", | ||
| "-------------------------------------------------------------------", | ||
| (hdr2 := f"Mon Nov 4 17:47:23 UTC 2024 - {dc}"), | ||
| "", | ||
| (content2 := "- # [0.9.37] - September 4th, 2024"), | ||
| "", | ||
| "-------------------------------------------------------------------", | ||
| ( | ||
| hdr3 := "Fri May 17 09:14:20 UTC 2024 - " | ||
| + "Dominique Leuenberger <[email protected]>" | ||
| ), | ||
| "", | ||
| (content3 := "- Use %patch -P N instead of deprecated %patchN syntax."), | ||
| "", | ||
| "-------------------------------------------------------------------", | ||
| ( | ||
| hdr4 := "Mon Oct 10 13:27:24 UTC 2022 - Stephan Kulow <[email protected]>" | ||
| ), | ||
| "", | ||
| (content4_1 := "updated to version 0.9.28"), | ||
| (content4_2 := " see installed CHANGELOG.md"), | ||
| "", | ||
| "", | ||
| "-------------------------------------------------------------------", | ||
| ( | ||
| hdr5 := "Fri Jun 25 07:31:34 UTC 2021 - Dan Čermák <[email protected]>" | ||
| ), | ||
| "", | ||
| (content5_1 := "- New upstream release 0.9.26"), | ||
| "", | ||
| (content5_2 := " - Add support for Ruby 3.0 and fix tests"), | ||
| ( | ||
| content5_3 := " - Fix support for `frozen_string_literal: false`" | ||
| + " magic comments (#1363)" | ||
| ), | ||
| "", | ||
| "", | ||
| ], | ||
| ) | ||
| ) | ||
|
|
||
| assert isinstance(changelog, Changelog) | ||
| assert len(changelog) == 5 | ||
|
|
||
| for changelog_entry, hdr, content in zip( | ||
| changelog, | ||
| reversed((hdr1, hdr2, hdr3, hdr4, hdr5)), | ||
| reversed( | ||
| ( | ||
| [content1], | ||
| [content2], | ||
| [content3], | ||
| [content4_1, content4_2], | ||
| [content5_1, "", content5_2, content5_3], | ||
| ) | ||
| ), | ||
| ): | ||
|
|
||
| assert isinstance(changelog_entry, ChangelogEntry) | ||
| assert changelog_entry.evr is None | ||
| assert changelog_entry.header == _OPENSUSE_CHANGELOG_SEPARATOR + "\n" + hdr | ||
| assert changelog_entry.content == [""] + content | ||
| assert changelog_entry.extended_timestamp | ||
| assert changelog_entry.style == ChangelogStyle.openSUSE | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "timestamp,author,content,entry", | ||
| ( | ||
| [ | ||
| ( | ||
| datetime.datetime(2021, 6, 25, 7, 31, 34), | ||
| "Dan Čermák <[email protected]>", | ||
| content_1 := ["", "New upstream release 0.9.26"], | ||
| ChangelogEntry( | ||
| header=_OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Fri Jun 25 07:31:34 UTC 2021 - Dan Čermák <[email protected]>", | ||
| content=content_1, | ||
| ), | ||
| ), | ||
| ( | ||
| datetime.date(2021, 6, 25), | ||
| "Dan Čermák <[email protected]>", | ||
| content_2 := [ | ||
| "", | ||
| "New upstream release 0.26", | ||
| "Fixed a major regression in Foo", | ||
| ], | ||
| ChangelogEntry( | ||
| header=_OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Fri Jun 25 12:00:00 UTC 2021 - Dan Čermák <[email protected]>", | ||
| content=content_2, | ||
| ), | ||
| ), | ||
| ] | ||
| ), | ||
| ) | ||
| def test_create_opensuse_changelog_assemble( | ||
| timestamp: Union[datetime.datetime, datetime.date], | ||
| author: str, | ||
| content: List[str], | ||
| entry: ChangelogEntry, | ||
| ) -> None: | ||
| assert ( | ||
| ChangelogEntry.assemble( | ||
| timestamp, | ||
| author, | ||
| content, | ||
| style=ChangelogStyle.openSUSE, | ||
| append_newline=False, | ||
| ) | ||
| == entry | ||
| ) | ||
|
|
||
|
|
||
| def test_get_raw_section_data(): | ||
| tzinfo = datetime.timezone(datetime.timedelta(hours=2), name="CEST") | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.