get_git_head_committer_date#

technote.metadata.builddate.get_git_head_committer_date(source_dir)#

Get the committer date of the checked-out commit.

Parameters:

source_dir (Path) – A directory inside the git repository (typically the technote’s source directory).

Returns:

The committer date of HEAD, in UTC, or None if that date cannot be read.

Return type:

datetime.datetime or None

Notes

Two outcomes are ordinary states of a technote that is being authored locally, so they return None silently: source_dir is not inside a git repository, and the repository has no commits yet.

Every other failure returns None and emits a Sphinx warning, because the caller is about to substitute the build clock and the resulting technote is neither reproducible nor dated by its publication event. Those failures are: git is not installed, the subprocess times out, git exits non-zero for any other reason (for example refusing a repository with dubious ownership, which is what git does to a checkout owned by another user in a CI container), git prints nothing, and git’s output cannot be parsed as a date. The warning carries the technote type and date_updated subtype, so a build that genuinely cannot reach git can silence it with suppress_warnings = ["technote.date_updated"] in conf.py.

The committer date of HEAD is available on a depth-1 checkout, so this works in CI without fetching history.

--no-show-signature is required because a user’s git configuration may set log.showSignature = true. With that setting, git log on a signed commit (every merge commit made through the GitHub UI is signed) prints gpg: verification lines to stdout ahead of the date, which would defeat the date parsing and silently fall back to the build clock.