mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Use new git lfs (broken due to lfs returning non-lfs files)
This commit is contained in:
parent
e11d94cfba
commit
0c5f040a7f
3 changed files with 8 additions and 21 deletions
|
|
@ -4,6 +4,7 @@ from __future__ import print_function
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
|
||||
|
|
@ -13,23 +14,13 @@ from pre_commit_hooks.util import cmd_output
|
|||
|
||||
|
||||
def lfs_files():
|
||||
try: # pragma: no cover (no git-lfs)
|
||||
lines = cmd_output('git', 'lfs', 'status', '--porcelain').splitlines()
|
||||
try:
|
||||
# Introduced in git-lfs 2.2.0, first working in 2.2.1
|
||||
lfs_ret = cmd_output('git', 'lfs', 'status', '--json')
|
||||
except CalledProcessError: # pragma: no cover (with git-lfs)
|
||||
lines = []
|
||||
lfs_ret = '{"files":{}}'
|
||||
|
||||
modes_and_fileparts = [
|
||||
(line[:3].strip(), line[3:].rpartition(' ')[0]) for line in lines
|
||||
]
|
||||
|
||||
def to_file_part(mode, filepart): # pragma: no cover (no git-lfs)
|
||||
assert mode in ('A', 'R')
|
||||
return filepart if mode == 'A' else filepart.split(' -> ')[1]
|
||||
|
||||
return {
|
||||
to_file_part(mode, filepart) for mode, filepart in modes_and_fileparts
|
||||
if mode in ('A', 'R')
|
||||
}
|
||||
return set(json.loads(lfs_ret)['files'])
|
||||
|
||||
|
||||
def find_large_added_files(filenames, maxkb):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue