You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am receiving a ValueError exception when getting the author date of a commit in Rails project. You can replicate it with the following code:
> from git import Repo
> repo = Repo('rails')
> commit = repo.commit('4cf94979c9f4d6683c9338d694d5eb3106a4e734')
> commit.authored_datetime
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/dspadini/Documents/pydriller/.venv/lib/python3.6/site-packages/git/objects/commit.py", line 151, in authored_datetime
return from_timestamp(self.authored_date, self.author_tz_offset)
File "/Users/dspadini/Documents/pydriller/.venv/lib/python3.6/site-packages/git/objects/util.py", line 124, in from_timestamp
> local_dt = utc_dt.astimezone(tzoffset(tz_offset))
ValueError: offset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24).
Tracing back the error, I got that the timestamp of the commit is 1312735823, while the tz_offset is -1864800. The problem is when creating the tzoffset: I indeed printed the timedelta
local_dt = utc_dt.astimezone(tzoffset(tz_offset))
class tzoffset(tzinfo):
def __init__(self, secs_west_of_utc, name=None):
self._offset = timedelta(seconds=-secs_west_of_utc)
print('Timedelta is {}'.format(timedelta(seconds=-secs_west_of_utc)))
and it is not in the range of [-24,24] hours, but it is actually 21 days.
EDIT: looking at the information of the commit, the offset is completely wrong: Date: Mon Aug 29 06:50:23 2011 +51800
So the problem is not of gitpython.
The text was updated successfully, but these errors were encountered:
In a way, it’s a denyal of service attack against GitPython, as it should certainly not choke on it the way it does.
Maybe it’s something worth fixing for that reason.
I was looking at how jGit solved it, and they simply return UTC timestamp if they fail in retrieving the timestamp of the commit. If you also agree with this solution, I can submit a PR tomorrow (I am UTC+2 ;) )
On Tue 3. Apr 2018 at 20:31, Spadini Davide ***@***.***> wrote:
I was looking at how jGit solved it, and they simply return UTC timestamp
if they fail in retrieving the timestamp of the commit. If you also agree
with this solution, I can submit a PR tomorrow (I am UTC+2 ;) )
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#741 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAD4hkfCD5VFQU0OF_wwRSMvV2SbsWYpks5tk8AUgaJpZM4TBdf_>
.
I am receiving a
ValueError
exception when getting the author date of a commit in Rails project. You can replicate it with the following code:Tracing back the error, I got that the timestamp of the commit is 1312735823, while the tz_offset is -1864800. The problem is when creating the tzoffset: I indeed printed the timedelta
and it is not in the range of [-24,24] hours, but it is actually 21 days.
EDIT: looking at the information of the commit, the offset is completely wrong:
Date: Mon Aug 29 06:50:23 2011 +51800
So the problem is not of gitpython.
The text was updated successfully, but these errors were encountered: