File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 55import os
66import re
77import shlex
8+ import sys
89import warnings
910
1011from datetime import date
@@ -119,6 +120,8 @@ def parse_timestamp(timestamp_text: str) -> date | None:
119120 if "%c" in timestamp_text :
120121 log .warning ("git too old -> timestamp is %r" , timestamp_text )
121122 return None
123+ if sys .version_info < (3 , 11 ) and timestamp_text .endswith ("Z" ):
124+ timestamp_text = timestamp_text [:- 1 ] + "+00:00"
122125 return datetime .fromisoformat (timestamp_text ).date ()
123126
124127 res = run_git (
Original file line number Diff line number Diff line change @@ -498,6 +498,22 @@ def test_git_getdate_badgit(
498498 assert git_wd .get_head_date () is None
499499
500500
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+
501517@pytest .fixture ()
502518def signed_commit_wd (monkeypatch : pytest .MonkeyPatch , wd : WorkDir ) -> WorkDir :
503519 if not has_command ("gpg" , args = ["--version" ], warn = False ):
You can’t perform that action at this time.
0 commit comments