mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:59:37 +08:00
* chore: keep Next build output out of Git * chore: enforce repository hygiene in CI * chore: enforce clean primary workspaces * chore: block accidental main commits * fix: make repository hygiene hook fail fast --------- Co-authored-by: XZH <cto@xzh.ai> Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Require a clean checkout in addition to clean tracked repository content."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def run_git(arguments: list[str]) -> subprocess.CompletedProcess[str]:
|
|
return subprocess.run(
|
|
["git", *arguments],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
|
|
def dirty_entries() -> list[str]:
|
|
result = run_git(["status", "--porcelain=v1", "--untracked-files=all"])
|
|
if result.returncode != 0:
|
|
raise SystemExit(result.stderr.strip() or "Unable to inspect Git status.")
|
|
return [line for line in result.stdout.splitlines() if line.strip()]
|
|
|
|
|
|
def tracked_hygiene() -> int:
|
|
result = subprocess.run(
|
|
[sys.executable, "scripts/check_repo_hygiene.py"],
|
|
check=False,
|
|
)
|
|
return result.returncode
|
|
|
|
|
|
def main() -> int:
|
|
entries = dirty_entries()
|
|
if entries:
|
|
print(
|
|
"Dirty checkout found; move work to a task worktree before proceeding:",
|
|
file=sys.stderr,
|
|
)
|
|
print("\n".join(entries), file=sys.stderr)
|
|
return 1
|
|
return tracked_hygiene()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|