File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 5
5
import os
6
6
import re
7
7
import shlex
8
+ import sys
8
9
import warnings
9
10
10
11
from datetime import date
@@ -119,6 +120,8 @@ def parse_timestamp(timestamp_text: str) -> date | None:
119
120
if "%c" in timestamp_text :
120
121
log .warning ("git too old -> timestamp is %r" , timestamp_text )
121
122
return None
123
+ if sys .version_info < (3 , 11 ) and timestamp_text .endswith ("Z" ):
124
+ timestamp_text = timestamp_text [:- 1 ] + "+00:00"
122
125
return datetime .fromisoformat (timestamp_text ).date ()
123
126
124
127
res = run_git (
Original file line number Diff line number Diff line change @@ -498,6 +498,22 @@ def test_git_getdate_badgit(
498
498
assert git_wd .get_head_date () is None
499
499
500
500
501
+ def test_git_getdate_git_2_45_0_plus (
502
+ wd : WorkDir , caplog : pytest .LogCaptureFixture , monkeypatch : pytest .MonkeyPatch
503
+ ) -> None :
504
+ wd .commit_testfile ()
505
+ git_wd = git .GitWorkdir (wd .cwd )
506
+ fake_date_result = CompletedProcess (
507
+ args = [], stdout = "2024-04-30T22:33:10Z" , stderr = "" , returncode = 0
508
+ )
509
+ with patch .object (
510
+ git ,
511
+ "run_git" ,
512
+ Mock (return_value = fake_date_result ),
513
+ ):
514
+ assert git_wd .get_head_date () == date (2024 , 4 , 30 )
515
+
516
+
501
517
@pytest .fixture ()
502
518
def signed_commit_wd (monkeypatch : pytest .MonkeyPatch , wd : WorkDir ) -> WorkDir :
503
519
if not has_command ("gpg" , args = ["--version" ], warn = False ):
You can’t perform that action at this time.
0 commit comments