Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/resolve_md/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ def get_git_last_updated(file_path: str, has_git: bool = True) -> str:
)
ts = result.stdout.strip()
if ts:
# Python 3.10 fromisoformat() doesn't accept 'Z'; normalize to +00:00
if ts.endswith("Z"):
ts = ts[:-1] + "+00:00"
return datetime.fromisoformat(ts).astimezone(timezone.utc).isoformat()
except (subprocess.SubprocessError, OSError):
pass
Expand Down
8 changes: 8 additions & 0 deletions tests/resolve_md/test_resolve_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import tempfile
from pathlib import Path
from unittest.mock import patch

import yaml

Expand Down Expand Up @@ -148,6 +149,13 @@ def test_returns_iso_timestamp_for_tracked_file(self):
assert ts, "Expected a non-empty timestamp"
assert "T" in ts, "Expected ISO-8601 format with a T separator"

def test_handles_z_suffix_on_python310(self):
"""Timestamps ending with 'Z' are normalised so Python 3.10 can parse them."""
mock_result = type("R", (), {"stdout": "2026-03-09T14:16:33Z", "returncode": 0})()
with patch("plugins.resolve_md.plugin.subprocess.run", return_value=mock_result):
ts = ResolveMDPlugin.get_git_last_updated(__file__)
assert ts == "2026-03-09T14:16:33+00:00"

def test_falls_back_for_untracked_file(self):
"""An untracked temp file falls back to filesystem mtime."""
with tempfile.NamedTemporaryFile(suffix=".md", delete=False) as f:
Expand Down