From be0df27cdc3e3f4c25b58fa23d977c10a508185f Mon Sep 17 00:00:00 2001 From: "njzjz-bot (driven by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5))[bot]" <48687836+njzjz-bot@users.noreply.github.com> Date: Sat, 30 May 2026 13:16:24 +0000 Subject: [PATCH] fix(authors): avoid fetching blobs for shallow history Fetch complete commit history with blob filtering on Read the Docs so git shortlog can produce a full author list without downloading repository contents when the server supports partial clone. Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5) --- deepmodeling_sphinx/authors.py | 36 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/deepmodeling_sphinx/authors.py b/deepmodeling_sphinx/authors.py index 5f5200e..1247977 100644 --- a/deepmodeling_sphinx/authors.py +++ b/deepmodeling_sphinx/authors.py @@ -2,12 +2,36 @@ import os import subprocess +import warnings from typing import Any, Dict, Iterator from sphinx.application import Sphinx from sphinx.util.docutils import SphinxDirective +def _is_shallow_repository() -> bool: + """Return whether the current repository is shallow.""" + return ( + subprocess.check_output(["git", "rev-parse", "--is-shallow-repository"]) + .decode("utf-8") + .strip() + == "true" + ) + + +def _fetch_full_history() -> None: + """Fetch complete history without downloading blob contents when possible.""" + try: + subprocess.check_call(["git", "fetch", "--unshallow", "--filter=blob:none"]) + except subprocess.CalledProcessError: + warnings.warn( + "Unable to fetch the complete git history with --filter=blob:none. " + "The generated author list may be incomplete.", + RuntimeWarning, + stacklevel=2, + ) + + def git_shortlog() -> str: """Return git-shortlog output as a string. @@ -16,16 +40,8 @@ def git_shortlog() -> str: str Git-shortlog output. """ - if os.environ.get("READTHEDOCS", None) == "True": - # check if it shallow clone - output_git_rev_parse = ( - subprocess.check_output(["git", "rev-parse", "--is-shallow-repository"]) - .decode("utf-8") - .strip() - ) - if output_git_rev_parse == "true": - # fetch full history - subprocess.check_output(["git", "fetch", "--unshallow"]) + if os.environ.get("READTHEDOCS", None) == "True" and _is_shallow_repository(): + _fetch_full_history() return subprocess.check_output(["git", "shortlog", "HEAD", "-s"]).decode("utf-8")