Skip to content

Commit 622bf4a

Browse files
committed
pre-commit: tolerate PKGBUILD encoding issues
pacman-static has a non-utf8 encoding.
1 parent 61d1a54 commit 622bf4a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pre-commit

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ def git_ls_tree():
109109
return dirs, files, commits
110110

111111

112-
def git_open(filename):
112+
def git_open(filename, decode_errors='strict'):
113113
cmd = ['git', 'cat-file', 'blob', f'{GIT_BRANCH}:{filename}']
114114
with Popen(cmd, stdout=PIPE) as p:
115-
return StringIO(readutf8(p.stdout))
115+
return StringIO(p.stdout.read().decode('utf-8', errors=decode_errors))
116116

117117

118118
def git_listdir(path):
@@ -384,7 +384,8 @@ class RepoTreeTest(TestCase):
384384
# PKGBUILD may be added later by lilac
385385
continue
386386
pkgbuild_path = os.path.join(pkgpath(package), 'PKGBUILD')
387-
with git_open(pkgbuild_path) as pkgbuild_file:
387+
print('checking', pkgbuild_path)
388+
with git_open(pkgbuild_path, decode_errors='replace') as pkgbuild_file:
388389
pkgbuild = pkgbuild_file.read()
389390
if not (('replaces' in pkgbuild) or ('groups' in pkgbuild)):
390391
# only parse pkgbuild as srcinfo when necessory

0 commit comments

Comments
 (0)