protonfs.lfs module¶
git-LFS awareness: detect LFS tracking and the tiny pointer-stub files it leaves.
protonfs must never hash or upload a 130-byte git-LFS pointer stub as if it were real content (#32) – doing so would clobber the real object on Drive. These helpers let setup/scan recognise LFS-managed repos and their un-materialised stubs.
Added in version 1.0.0.
- protonfs.lfs.POINTER_SIGNATURE = 'version https://git-lfs.github.com/spec/v1'¶
First line every git-LFS pointer file carries; its presence identifies a stub.
- protonfs.lfs.find_pointer_stubs(root, subpath)[source]¶
Recursively find git-LFS pointer-stub files under
root(optionally scoped).Only files under 200 bytes are inspected (a real pointer is ~130 bytes), keeping the scan cheap.
- protonfs.lfs.is_lfs_tracked(repo_root)[source]¶
Return whether
repo_rootuses git-LFS.True when
.gitattributesdeclares afilter=lfsrule, orgit lfs ls-filesreports tracked objects.
- protonfs.lfs.is_pointer_stub(path)[source]¶
Return whether
pathis an un-materialised git-LFS pointer file.- Parameters:
path (
Path) – the file to test.- Return type:
- Returns:
Truewhen its first line is thePOINTER_SIGNATURE(an unreadable file returnsFalse).
- protonfs.lfs.lfs_tracked_paths(repo_root)[source]¶
Return the repo-relative paths git-LFS tracks (
git lfs ls-files -n).- Parameters:
repo_root (
Path) – the git repo root to inspect.- Return type:
- Returns:
the tracked paths, in git’s order; empty when LFS tracks no files.
- Raises:
RuntimeError – when
git lfs ls-filesfails, so a caller never mistakes “could not list” for “nothing tracked”.
Added in version 3.4.0.