31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Reject model files and their shards in the current Git index; does not scan history."""
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def forbidden_paths(tracked, resources):
|
|
files = {entry['path'] for group in resources for entry in group['files']
|
|
if not entry['path'].endswith('/config.yml')}
|
|
return [name for name in tracked
|
|
if name in files or any(name.startswith(path + '.part-') for path in files)
|
|
or Path(name).name in {'MANO_RIGHT.pkl', 'MANO_LEFT.pkl'}]
|
|
|
|
|
|
def main():
|
|
resources = json.loads((ROOT / 'configs/external_resources.json').read_text())['resources']
|
|
tracked = subprocess.check_output(['git', 'ls-files', '-z'], cwd=ROOT).decode().split('\0')
|
|
bad = forbidden_paths(tracked, resources)
|
|
for name in bad:
|
|
print(f'FAIL externally acquired resource is tracked: {name}')
|
|
if not bad:
|
|
print('PASS current Git index excludes external model payloads and shards; historical commits/LFS objects are not checked or removed.')
|
|
return int(bool(bad))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
raise SystemExit(main())
|