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, orNoneif 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
Nonesilently:source_diris not inside a git repository, and the repository has no commits yet.Every other failure returns
Noneand 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:gitis 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 thetechnotetype anddate_updatedsubtype, so a build that genuinely cannot reach git can silence it withsuppress_warnings = ["technote.date_updated"]inconf.py.The committer date of
HEADis available on a depth-1 checkout, so this works in CI without fetching history.--no-show-signatureis required because a user’s git configuration may setlog.showSignature = true. With that setting,git logon a signed commit (every merge commit made through the GitHub UI is signed) printsgpg:verification lines to stdout ahead of the date, which would defeat the date parsing and silently fall back to the build clock.