Skip to content

Commit 1ed26c1

Browse files
committed
fix: auto-push LFS objects in pre-push hook; skip LFS pointers in validator
- Add git-lfs-push hook to .pre-commit-config.yaml so LFS objects are uploaded automatically (pre-commit replaces git-lfs's own hook) - Detect Git LFS pointer files in validate.py and skip media checks instead of failing with "moov atom not found" Made-with: Cursor
1 parent 16c3711 commit 1ed26c1

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ repos:
66
- id: check-added-large-files
77
args: ['--maxkb=1000']
88

9+
# Upload LFS objects (pre-commit replaces git-lfs's own pre-push hook)
10+
- repo: local
11+
hooks:
12+
- id: git-lfs-push
13+
name: git lfs push
14+
entry: bash -c 'git lfs push origin HEAD --all'
15+
language: system
16+
stages: [pre-push]
17+
pass_filenames: false
18+
always_run: true
19+
920
# Validate demo recordings (A/V drift, narration lint) before push
1021
- repo: local
1122
hooks:

src/docgen/validate.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ def _sample_frames(path: Path, interval_sec: float = 2.0) -> list[tuple[float, n
7676
return samples
7777

7878

79+
_LFS_SIGNATURE = b"version https://git-lfs.github.com/spec/v1"
80+
81+
82+
def _is_lfs_pointer(path: Path) -> bool:
83+
"""Return True if *path* is a Git LFS pointer file (not actual media)."""
84+
try:
85+
with open(path, "rb") as f:
86+
return f.read(len(_LFS_SIGNATURE)) == _LFS_SIGNATURE
87+
except OSError:
88+
return False
89+
90+
7991
class Validator:
8092
def __init__(self, config: Config) -> None:
8193
self.config = config
@@ -92,7 +104,11 @@ def validate_segment(
92104
report = ValidationReport(segment=seg_id)
93105
rec = self._find_recording(seg_id)
94106

95-
if rec:
107+
if rec and _is_lfs_pointer(rec):
108+
report.checks.append(
109+
CheckResult("lfs_pointer", True, [f"LFS pointer — skipping media checks for {seg_id}"])
110+
)
111+
elif rec:
96112
report.checks.append(self._check_streams(rec))
97113
max_drift = max_drift_override or self.config.max_drift_sec
98114
report.checks.append(self._check_drift(rec, max_drift))

0 commit comments

Comments
 (0)