Skip to content

Add author and timestamp properties to ChangelogEntry - #482

Merged
centosinfra-prod-github-app[bot] merged 3 commits into
packit:mainfrom
dcermak:add-author-timestamp-property
Nov 10, 2026
Merged

centosinfra-prod-github-app[bot] merged 3 commits into
packit:mainfrom
dcermak:add-author-timestamp-property

Conversation

@dcermak

@dcermak dcermak commented Jun 15, 2025

Copy link
Copy Markdown
Contributor

These properties are required to convert Fedora to openSUSE style changelogs for packit

TODO:

  • Write new tests or update the old ones to cover new functionality.
  • Update doc-strings where appropriate.
  • [-] Update or write new documentation in packit/packit.dev.

Fixes

Related to

Merge before/after

RELEASE NOTES BEGIN

  • add support to parse the author and timestamp from changelog entries
    RELEASE NOTES END

@softwarefactory-delete-me

Copy link
Copy Markdown
Contributor

@dcermak

dcermak commented Jun 15, 2025

Copy link
Copy Markdown
Contributor Author

So, it looks like the tests only worked locally for me by accident, because I'm in the CEST timezone and I do have more timezone information available locally. To properly parse the timezone, we'd have to add another dependency. What's your opinion on this? Add a dependency or live with wrong timezones?

@majamassarini
majamassarini requested a review from nforro June 16, 2025 09:05
@majamassarini majamassarini moved this from new to in-review in Packit Kanban Board Jun 16, 2025

@nforro nforro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To properly parse the timezone, we'd have to add another dependency. What's your opinion on this? Add a dependency or live with wrong timezones?

That's one of the reasons this was never implemented. Wrong timezones are a no-go, if we are going to implement this, let's do it right.

Comment thread specfile/changelog.py Resolved
Comment thread specfile/changelog.py Outdated
if not self.evr:
return author_and_evr

if (gt_ind := author_and_evr.rfind(">")) > 0:

Copy link
Copy Markdown
Member

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 generic name property and then deriving author and evr from it?

Copy link
Copy Markdown
Contributor Author

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:

* Mon May 22 2023 $FirstName $LastName

Our evr regex will recognize $LastName as 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.

Copy link
Copy Markdown
Member

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

Comment thread specfile/changelog.py Resolved
@nforro

nforro commented Jun 16, 2025

Copy link
Copy Markdown
Member

To properly parse the timezone, we'd have to add another dependency

Perhaps adding another dependency could be avoided by matching the entries to RPM-parsed changelog - self.rpm_spec.sourceHeader[rpm.RPMTAG_CHANGELOGTIME] returns a list of Unix timestamps.

@lbarcziova lbarcziova moved this from New to In review in Packit pull requests Jan 9, 2026
@dcermak
dcermak force-pushed the add-author-timestamp-property branch 2 times, most recently from 82d5c62 to 646a94c Compare November 7, 2026 22:04
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@dcermak

dcermak commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

To properly parse the timezone, we'd have to add another dependency

Perhaps adding another dependency could be avoided by matching the entries to RPM-parsed changelog - self.rpm_spec.sourceHeader[rpm.RPMTAG_CHANGELOGTIME] returns a list of Unix timestamps.

I didn't go for the rpm.RPMTAG_CHANGELOGTIME mostly because rpm appears to drop entries older than %_changelog_trimage, which makes this pretty much unusable

And apologies for taking a literal eternity here :-(

Comment thread specfile/changelog.py Resolved
Comment thread specfile/changelog.py Resolved
Comment thread specfile/changelog.py Resolved
Comment thread specfile/changelog.py Resolved
Comment thread specfile/changelog.py Resolved
Comment thread specfile/changelog.py Resolved
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@nforro

nforro commented Nov 10, 2026

Copy link
Copy Markdown
Member

❌ pre-commit FAILURE in 1m 08s

I've fixed CI in #546, it should be green after rebase (except for the flaky CS10 tests).

dcermak and others added 3 commits November 10, 2026 16:23
Detection of extended timestamps didn't recognize zero-padded days of month,
so add_changelog_entry() would create changelog entries without a item in such a
case. Therefore we unify the code to use the same regex for extended_timestamp &
sanitize_day_of_month_padding.

Signed-off-by: Dan Čermák <dcermak@suse.com>
Assisted-By: Claude Opus 5.5
These properties are required to convert Fedora to openSUSE style changelogs
for packit.

Timezones are resolved the same way RPM resolves them, so that timestamps match
RPMTAG_CHANGELOGTIME: names missing in the timezone database (e.g. CEST) mean
UTC and DST is not applied

Signed-off-by: Dan Čermák <dcermak@suse.com>
Assisted-By: Claude Opus 5.5
Co-authored-by: Nikola Forró <nforro@redhat.com>
@dcermak
dcermak force-pushed the add-author-timestamp-property branch from fb73751 to 3f2d3e9 Compare November 10, 2026 15:30
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@nforro

nforro commented Nov 10, 2026

Copy link
Copy Markdown
Member

/packit retest-failed

@nforro

nforro commented Nov 10, 2026

Copy link
Copy Markdown
Member

/packit-stg retest-failed

@nforro nforro added the mergeit Merge via Zuul label Nov 10, 2026
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app
centosinfra-prod-github-app Bot merged commit 08ea423 into packit:main Nov 10, 2026
58 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Packit pull requests Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergeit Merge via Zuul

Projects

Status: in-review

Development

Successfully merging this pull request may close these issues.

2 participants