mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-30 10:16:54 +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
|
|
@ -8,9 +8,9 @@ from urllib.request import urlopen
|
|||
|
||||
DOWNLOAD_PATH = (
|
||||
'https://github.com/github/git-lfs/releases/download/'
|
||||
'v1.1.0/git-lfs-linux-amd64-1.1.0.tar.gz'
|
||||
'v2.2.1/git-lfs-linux-amd64-2.2.1.tar.gz'
|
||||
)
|
||||
PATH_IN_TAR = 'git-lfs-1.1.0/git-lfs'
|
||||
PATH_IN_TAR = 'git-lfs-2.2.1/git-lfs'
|
||||
DEST_PATH = '/tmp/git-lfs/git-lfs'
|
||||
DEST_DIR = os.path.dirname(DEST_PATH)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -79,10 +79,6 @@ xfailif_no_gitlfs = pytest.mark.xfail(
|
|||
@xfailif_no_gitlfs
|
||||
def test_allows_gitlfs(temp_git_dir): # pragma: no cover
|
||||
with temp_git_dir.as_cwd():
|
||||
# Work around https://github.com/github/git-lfs/issues/913
|
||||
cmd_output(
|
||||
'git', 'commit', '--no-gpg-sign', '--allow-empty', '-m', 'foo',
|
||||
)
|
||||
cmd_output('git', 'lfs', 'install')
|
||||
temp_git_dir.join('f.py').write('a' * 10000)
|
||||
cmd_output('git', 'lfs', 'track', 'f.py')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue