mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 15:20:30 +08:00
fix lefthook (#17023)
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -23,14 +24,17 @@ def _read_bytes(path: Path) -> bytes:
|
||||
return path.read_bytes()
|
||||
|
||||
|
||||
def _staged_paths() -> list[Path]:
|
||||
def _git_paths(*args: str) -> list[Path]:
|
||||
proc = subprocess.run(
|
||||
["git", "diff", "--cached", "--name-only", "--diff-filter=ACMR"],
|
||||
["git", *args, "-z"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
return [Path(line) for line in proc.stdout.splitlines() if line]
|
||||
return [Path(os.fsdecode(raw_path)) for raw_path in proc.stdout.split(b"\0") if raw_path]
|
||||
|
||||
|
||||
def _staged_paths() -> list[Path]:
|
||||
return _git_paths("diff", "--cached", "--name-only", "--diff-filter=ACMR")
|
||||
|
||||
|
||||
def _report(errors: list[str]) -> int:
|
||||
@@ -147,15 +151,10 @@ def check_symlinks(paths: list[Path], fix: bool = False) -> int:
|
||||
|
||||
|
||||
def check_case_conflicts(_: list[Path], fix: bool = False) -> int:
|
||||
proc = subprocess.run(
|
||||
["git", "ls-files"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
seen: dict[str, str] = {}
|
||||
errors: list[str] = []
|
||||
for path in proc.stdout.splitlines():
|
||||
for raw_path in _git_paths("ls-files"):
|
||||
path = str(raw_path)
|
||||
lowered = path.lower()
|
||||
other = seen.get(lowered)
|
||||
if other and other != path:
|
||||
|
||||
Reference in New Issue
Block a user