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.

Parameters:
  • root (Path) – the repo root.

  • subpath (Path) – subtree to scope the search to, or Path(".") for the whole root.

Return type:

list[Path]

Returns:

the stub files found, sorted.

protonfs.lfs.is_lfs_tracked(repo_root)[source]

Return whether repo_root uses git-LFS.

True when .gitattributes declares a filter=lfs rule, or git lfs ls-files reports tracked objects.

Parameters:

repo_root (Path) – the git repo root to inspect.

Return type:

bool

Returns:

True if the repo tracks anything through git-LFS.

protonfs.lfs.is_pointer_stub(path)[source]

Return whether path is an un-materialised git-LFS pointer file.

Parameters:

path (Path) – the file to test.

Return type:

bool

Returns:

True when its first line is the POINTER_SIGNATURE (an unreadable file returns False).