doc: gh_utils: ignore added-but-not-committed files

If the file is added to the index, but not committed yet, the 'git'
command will return an empty string. This patch checks for this case and
treats it as if the file was not tracked at all.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
Luca Burelli 2025-01-16 10:11:44 +01:00 committed by Benjamin Cabé
parent 7c50c0231c
commit f3bf6357c7

View file

@ -211,6 +211,8 @@ def git_info_filter(app: Sphinx, pagename) -> tuple[str, str] | None:
.decode("utf-8") .decode("utf-8")
.strip() .strip()
) )
if not date_and_sha1: # added but not committed
return None
date, sha1 = date_and_sha1.split(" ", 1) date, sha1 = date_and_sha1.split(" ", 1)
date_object = datetime.fromtimestamp(int(date)) date_object = datetime.fromtimestamp(int(date))
last_update_fmt = app.config.html_last_updated_fmt last_update_fmt = app.config.html_last_updated_fmt