-
Notifications
You must be signed in to change notification settings - Fork 20
Add author and timestamp properties to ChangelogEntry #482
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
Open
dcermak
wants to merge
1
commit into
packit:main
Choose a base branch
from
dcermak:add-author-timestamp-property
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 |
|---|---|---|
|
|
@@ -390,6 +390,150 @@ def test_create_opensuse_changelog_assemble( | |
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "changelog_entry, expected_author, expected_timestamp", | ||
| [ | ||
| # Standard Fedora/RPM style entries (basic date format) | ||
| ( | ||
| ChangelogEntry( | ||
| "* Thu Jan 04 2007 Michael Schwendt <[email protected]>", [""] | ||
| ), | ||
| "Michael Schwendt <[email protected]>", | ||
| datetime.datetime(2007, 1, 4, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Fri Jul 26 2024 Miroslav Suchý <[email protected]> - ss981107-67", | ||
| [""], | ||
| ), | ||
| "Miroslav Suchý <[email protected]>", | ||
| datetime.datetime(2024, 7, 26, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Mon Jul 13 2020 Tom Stellard <[email protected]> 4.0-0.4.pre2", | ||
| [""], | ||
| ), | ||
| "Tom Stellard <[email protected]>", | ||
| datetime.datetime(2020, 7, 13, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Thu Feb 04 2016 Marcin Zajaczkowski <mszpak ATT wp DOTT pl> - 1:0.9.10-6", | ||
| [""], | ||
| ), | ||
| "Marcin Zajaczkowski <mszpak ATT wp DOTT pl>", | ||
| datetime.datetime(2016, 2, 4, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Mon Jan 03 2022 Fedora Kernel Team <[email protected]> " | ||
| "[5.16-0.rc8.55]", | ||
| [""], | ||
| ), | ||
| "Fedora Kernel Team <[email protected]>", | ||
| datetime.datetime(2022, 1, 3, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Wed Jan 23 2002 Karsten Hopp <[email protected]> (4.6-1)", [""] | ||
| ), | ||
| "Karsten Hopp <[email protected]>", | ||
| datetime.datetime(2002, 1, 23, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Thu Apr 9 2015 Jeffrey C. Ollie <[email protected]> - 13.3.2-1:", [""] | ||
| ), | ||
| "Jeffrey C. Ollie <[email protected]>", | ||
| datetime.datetime(2015, 4, 9, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| # Standard format with extended timestamp | ||
| ( | ||
| ChangelogEntry( | ||
| "* Mon Oct 18 12:34:45 CEST 2021 Nikola Forró <[email protected]> - 0.2-1", | ||
| [""], | ||
| ), | ||
| "Nikola Forró <[email protected]>", | ||
| datetime.datetime(2021, 10, 18, 12, 34, 45, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| "* Mon Feb 23 2009 Fedora Release Engineering <[email protected]>" | ||
| " - 1.23-3.20081106gitbe42b4", | ||
| [""], | ||
| ), | ||
| "Fedora Release Engineering <[email protected]>", | ||
| datetime.datetime(2009, 2, 23, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| # Entry without EVR | ||
| ( | ||
| ChangelogEntry("* Mon May 22 2023 Nikola Forró <[email protected]>", [""]), | ||
| "Nikola Forró <[email protected]>", | ||
| datetime.datetime(2023, 5, 22, 12, 0, 0, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| # openSUSE/SUSE style entries (always extended format) | ||
| ( | ||
| ChangelogEntry( | ||
| _OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Tue Dec 17 14:21:37 UTC 2024 - Dan Čermák <[email protected]>", | ||
| [""], | ||
| ), | ||
| "Dan Čermák <[email protected]>", | ||
| datetime.datetime(2024, 12, 17, 14, 21, 37, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| _OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Mon Nov 4 17:47:23 UTC 2024 - Dan Čermák <[email protected]>", | ||
| [""], | ||
| ), | ||
| "Dan Čermák <[email protected]>", | ||
| datetime.datetime(2024, 11, 4, 17, 47, 23, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| _OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Fri May 17 09:14:20 UTC 2024 - Dominique Leuenberger <[email protected]>", | ||
| [""], | ||
| ), | ||
| "Dominique Leuenberger <[email protected]>", | ||
| datetime.datetime(2024, 5, 17, 9, 14, 20, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| _OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Mon Oct 10 13:27:24 UTC 2022 - Stephan Kulow <[email protected]>", | ||
| [""], | ||
| ), | ||
| "Stephan Kulow <[email protected]>", | ||
| datetime.datetime(2022, 10, 10, 13, 27, 24, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ( | ||
| ChangelogEntry( | ||
| _OPENSUSE_CHANGELOG_SEPARATOR | ||
| + "\n" | ||
| + "Fri Jun 25 07:31:34 UTC 2021 - Dan Čermák <[email protected]>", | ||
| [""], | ||
| ), | ||
| "Dan Čermák <[email protected]>", | ||
| datetime.datetime(2021, 6, 25, 7, 31, 34, tzinfo=datetime.timezone.utc), | ||
| ), | ||
| ], | ||
| ) | ||
| def test_author_timestamp( | ||
| changelog_entry: ChangelogEntry, | ||
| expected_author: str, | ||
| expected_timestamp: datetime.datetime, | ||
| ): | ||
| assert changelog_entry.author == expected_author | ||
| assert changelog_entry.timestamp == expected_timestamp | ||
|
|
||
|
|
||
| def test_get_raw_section_data(): | ||
| tzinfo = datetime.timezone(datetime.timedelta(hours=2), name="CEST") | ||
| changelog = Changelog( | ||
|
|
||
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.
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.
This assumes the author substring always ends with a specifically formatted e-mail, but that doesn't have to be the case, even though Fedora Packaging Guidelines mandate so. specfile should be able to parse any format supported by RPM, which allows any string after the timestamp (ended by a newline) - and refers to it as
name. What about adding a more genericnameproperty and then derivingauthorandevrfrom it?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 have refactored the code a bit, so that it no longer relies on the
>character to be present. But I am not sure if we should try to parse such a changelog correctly anyway. Imagine the following entry:Our evr regex will recognize
$LastNameas the EVR in this case and given that we allow anything as the evr, there's no way to distinguish it from a last name. At least nothing immediate comes to my mind.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.
That's true, but there are lots of spec files with changelog entries like this, for example:
https://src.fedoraproject.org/rpms/gdb/blob/rawhide/f/gdb.spec#_1516
https://src.fedoraproject.org/rpms/rpm-spec-language-server/blob/rawhide/f/rpm-spec-language-server.spec#_72
We could try to recognize these formats, and document that author/EVR parsing is best effort and doesn't have to be accurate:
* timestamp author - EVR* timestamp author [EVR]* timestamp author (EVR)* timestamp author