This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow-site.git
The following commit(s) were added to refs/heads/main by this push:
new ee7011fcf1 Exclude gitignored files from sphinx theme hash computation
(#1582)
ee7011fcf1 is described below
commit ee7011fcf1077e5d80fb9795c7f770fde5922dfa
Author: Andrew Chang <[email protected]>
AuthorDate: Wed Jul 1 16:12:08 2026 +0000
Exclude gitignored files from sphinx theme hash computation (#1582)
compute_theme_hash walks THEME_MODULE.rglob("*") and only skips __pycache__
and .DS_Store. Any other gitignored path — most notably
sphinx_airflow_theme/sphinx_airflow_theme/static/_gen/ populated by
./site.sh build-site — is included in the hash, so its presence changes the
result.
_gen/ exists locally after building but never on a fresh CI checkout, so
contributors who follow the documented workflow commit a hash CI cannot
reproduce, and the check-sphinx-theme-version prek hook enters an infinite
"bump version" loop between local commits and CI complaints.
Filter the file list through git ls-files --others --ignored
--exclude-standard so the same rules a fresh checkout applies are used
here. The hash computed by this change on upstream main is identical to
the currently-stored hash, so no version bump is triggered by the fix
itself.
---
sphinx_airflow_theme/check_and_bump_version.py | 31 ++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/sphinx_airflow_theme/check_and_bump_version.py
b/sphinx_airflow_theme/check_and_bump_version.py
index 89395395ab..0dad24213c 100755
--- a/sphinx_airflow_theme/check_and_bump_version.py
+++ b/sphinx_airflow_theme/check_and_bump_version.py
@@ -40,15 +40,46 @@ VERSION_FILE = THEME_DIR / "LATEST_VERSION.txt"
INIT_FILE = THEME_MODULE / "__init__.py"
+def _gitignored_paths_under(directory: Path) -> set[str]:
+ """Return the set of gitignored file paths under *directory*, relative to
REPO_ROOT.
+
+ Uses ``git ls-files --others --ignored --exclude-standard`` so the same
rules
+ a fresh CI checkout applies are used here — otherwise files that only exist
+ locally (e.g. ``static/_gen/`` populated by ``./site.sh build-site``) would
+ make the local hash diverge from the one CI computes.
+ """
+ try:
+ output = subprocess.check_output(
+ [
+ "git",
+ "ls-files",
+ "--others",
+ "--ignored",
+ "--exclude-standard",
+ "--",
+ str(directory),
+ ],
+ cwd=REPO_ROOT,
+ text=True,
+ )
+ except subprocess.CalledProcessError:
+ return set()
+ return {line.strip() for line in output.splitlines() if line.strip()}
+
+
def compute_theme_hash() -> str:
"""Hash all theme files (excluding version lines in __init__.py) plus
pyproject.toml.
File paths are included as relative paths so the hash is stable regardless
of working directory.
+ Gitignored paths are skipped so the hash matches on any checkout (local or
CI).
"""
h = hashlib.sha256()
+ gitignored = _gitignored_paths_under(THEME_MODULE)
for f in sorted(THEME_MODULE.rglob("*")):
if not f.is_file() or "__pycache__" in f.parts or f.name ==
".DS_Store":
continue
+ if str(f.relative_to(REPO_ROOT)) in gitignored:
+ continue
relative = f.relative_to(REPO_ROOT)
h.update(f"{relative}\n".encode())
if f == INIT_FILE: