Skip to content

Commit e2f8367

Browse files
committed
Fix parse_date typing 5
1 parent 024b696 commit e2f8367

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎git/objects/util.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,10 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
187187
offset = -int(utcoffset.total_seconds())
188188
return int(string_date.astimezone(utc).timestamp()), offset
189189
else:
190-
raise ValueError(f"Unsupported date format or type: {string_date}" % string_date)
190+
raise ValueError(f"string_date datetime object without tzinfo, {string_date}")
191191

192-
else:
192+
# git time
193+
try:
193194
if string_date.count(' ') == 1 and string_date.rfind(':') == -1:
194195
timestamp, offset_str = string_date.split()
195196
if timestamp.startswith('@'):
@@ -243,9 +244,13 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
243244
continue
244245
# END exception handling
245246
# END for each fmt
247+
246248
# still here ? fail
247249
raise ValueError("no format matched")
248250
# END handle format
251+
except Exception as e:
252+
raise ValueError(f"Unsupported date format or type: {string_date}" % string_date) from e
253+
# END handle exceptions
249254

250255

251256
# precompiled regex

0 commit comments

Comments
 (0)