◐ Shell
clean mode source ↗

Fix check-added-large-files --enforce-all to correctly consider all git-lfs files. by amartani · Pull Request #674 · pre-commit/pre-commit-hooks

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. I've been investigating alternatives here, but I couldn't come up with a good one.

The main issue that I'm concerned with is that it is relatively easy to end up with a file that is marked with filter=lfs in gitattributes but is not actually using git-lfs:

  • If you don't have git-lfs installed, then git will just ignore the lfs filter and will commit as a regular file.
  • If you have it installed, but you edit gitattributes directly instead of using git lfs track and you don't git add --renormalize, then the files are also committed as regular files.

As an aside - it would be great to have a pre-commit check that catches these cases, checking that all files that have filter=lfs in gitattributes are actually being tracked by git-lfs. If you know a good way of enforcing that, then it would be easier to switch this to something else based on git check-attr