-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Resolve SOURCE_DATE_EPOCH=0
bug.
#3795
Conversation
Not clear to me if... * There may also be a timezone issue here leading to the negative value. And furthermore... * Non-integer values will still raise an exception here. But this does at least resolve the immediate issue.
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 for the quick fix @tomchristie. Just wondering what the issue exactly was.
mkdocs/utils/__init__.py
Outdated
@@ -56,7 +56,7 @@ def get_build_timestamp(*, pages: Collection[Page] | None = None) -> int: | |||
dt = datetime.fromisoformat(date_string) | |||
else: | |||
dt = get_build_datetime() | |||
return int(dt.timestamp()) | |||
return max(int(dt.timestamp()), 0) |
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'm not sure to understand the fix (but believe you that it actually fixes the issue). Is it a timezone-aware/naive issue? I gather int(dt.timestamp())
would return a negative integer when there are no pages and SOURCE_DATE_EPOCH=0
? But why 🤔?
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.
Should we add an actual test by the way? To prevent any regression.
@@ -53,7 +53,7 @@ def get_build_timestamp(*, pages: Collection[Page] | None = None) -> int: | |||
if pages: | |||
# Lexicographic comparison is OK for ISO date. | |||
date_string = max(p.update_date for p in pages) | |||
dt = datetime.fromisoformat(date_string) | |||
dt = datetime.fromisoformat(date_string).replace(tzinfo=timezone.utc) |
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.
The issue is that we're using utc
timezone datetimes everywhere, except here.
The robust fix is that we update this naive timezone into a utc
based timezone.
Thanks! |
Closes #3794
Not clear to me if...
And furthermore...
But this does at least resolve the immediate issue.
Thanks to @vedranmiletic for raising the issue and @pawamoy for the confimation.