mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
Add a pre-commit for distro_codegen but it does not work yet
This commit is contained in:
parent
57a9b4d57f
commit
3aedde2ab4
8 changed files with 66 additions and 4 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
import concurrent.futures
|
||||
import importlib
|
||||
import subprocess
|
||||
import sys
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
from typing import Iterator
|
||||
|
@ -55,6 +57,16 @@ def process_template(template_dir: Path, progress) -> None:
|
|||
raise e
|
||||
|
||||
|
||||
def check_for_changes() -> bool:
|
||||
"""Check if there are any uncommitted changes."""
|
||||
result = subprocess.run(
|
||||
["git", "diff", "--exit-code"],
|
||||
cwd=REPO_ROOT,
|
||||
capture_output=True,
|
||||
)
|
||||
return result.returncode != 0
|
||||
|
||||
|
||||
def main():
|
||||
templates_dir = REPO_ROOT / "llama_stack" / "templates"
|
||||
|
||||
|
@ -76,6 +88,15 @@ def main():
|
|||
list(executor.map(process_func, template_dirs))
|
||||
progress.update(task, advance=len(template_dirs))
|
||||
|
||||
if check_for_changes():
|
||||
print(
|
||||
"Distribution template changes detected. Please commit the changes.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue