Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around a change in Git's behavior #46

Merged
merged 1 commit into from
May 21, 2024
Merged
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
18 changes: 15 additions & 3 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dataclasses import dataclass
import json
from pathlib import Path
import re
import subprocess
from typing import Any

Expand All @@ -25,8 +26,10 @@ def readcmd(self, *args: str | Path) -> str:
return r.stdout.strip()

def get_tag_date(self, tag: str) -> str:
return self.readcmd(
"for-each-ref", "--format=%(creatordate:iso-strict)", f"refs/tags/{tag}"
return unzulu(
self.readcmd(
"for-each-ref", "--format=%(creatordate:iso-strict)", f"refs/tags/{tag}"
)
)

def get_tag_creator(self, tag: str) -> str:
Expand All @@ -36,7 +39,9 @@ def get_tag_creator(self, tag: str) -> str:
)

def get_commit_date(self, commitish: str) -> str:
return self.readcmd("show", "-s", "--format=%aI", f"{commitish}^{{commit}}")
return unzulu(
self.readcmd("show", "-s", "--format=%aI", f"{commitish}^{{commit}}")
)

def get_commit_author(self, commitish: str) -> str:
return self.readcmd(
Expand Down Expand Up @@ -115,3 +120,10 @@ def find_filepaths(dirpath: Path) -> Iterator[Path]:
exclude_vcs=False,
),
)


def unzulu(ts: str) -> str:
# Git v2.45.0 changed its iso-strict date format to display the UTC offset
# as "Z" rather than "+00:00", which breaks comparisons against stringified
# Python datetimes.
return re.sub(r"Z$", "+00:00", ts)