mirror of
https://github.com/kvcache-ai/sglang.git
synced 2026-06-30 11:48:01 +00:00
60 lines
1.4 KiB
Python
Executable File
60 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Reject staged changes under the legacy docs/ tree."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
ERROR_MESSAGE = """\
|
|
Changes under the legacy docs/ directory are not allowed.
|
|
|
|
The documentation has been migrated. Please make documentation updates in the
|
|
corresponding location under docs_new/ instead.
|
|
"""
|
|
|
|
LEGACY_DOCS_ALLOWLIST = {
|
|
"docs/_static/css/custom_log.css",
|
|
"docs/_static/js/deprecation_banner.js",
|
|
"docs/conf.py",
|
|
}
|
|
|
|
|
|
def staged_paths() -> list[str]:
|
|
result = subprocess.run(
|
|
[
|
|
"git",
|
|
"diff",
|
|
"--cached",
|
|
"--name-only",
|
|
"--diff-filter=ACMRDTUXB",
|
|
],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
return [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
|
|
|
|
|
def main() -> int:
|
|
paths = sys.argv[1:] or staged_paths()
|
|
docs_paths = sorted(
|
|
path
|
|
for path in paths
|
|
if (path == "docs" or path.startswith("docs/"))
|
|
and path not in LEGACY_DOCS_ALLOWLIST
|
|
)
|
|
|
|
if not docs_paths:
|
|
return 0
|
|
|
|
print(ERROR_MESSAGE, file=sys.stderr)
|
|
print("Detected legacy docs/ changes:", file=sys.stderr)
|
|
for path in docs_paths:
|
|
print(f" - {path}", file=sys.stderr)
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|