Fix Windows git commit ValueError: embedded null character.
Use git commit -F and strip NULs from argv/version strings (0.3.7). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -76,6 +76,11 @@ def read_config_name(src_root: Path) -> str | None:
|
||||
return read_config_identity(src_root).name
|
||||
|
||||
|
||||
def _sanitize_text(s: str) -> str:
|
||||
"""Drop NULs (UTF-16 mis-reads / dirty dumps) that break Windows APIs."""
|
||||
return s.replace("\0", "").strip()
|
||||
|
||||
|
||||
def read_config_identity(src_root: Path) -> ConfigIdentity:
|
||||
"""Version, Name, Synonym (ru), Vendor from dump."""
|
||||
src_root = Path(src_root)
|
||||
@@ -84,7 +89,9 @@ def read_config_identity(src_root: Path) -> ConfigIdentity:
|
||||
version = "unknown"
|
||||
version_file = root / "VERSION"
|
||||
if version_file.is_file():
|
||||
text = version_file.read_text(encoding="utf-8-sig", errors="ignore").strip()
|
||||
text = _sanitize_text(
|
||||
version_file.read_text(encoding="utf-8-sig", errors="ignore")
|
||||
)
|
||||
if text:
|
||||
version = text.splitlines()[0].strip()
|
||||
|
||||
@@ -103,22 +110,22 @@ def read_config_identity(src_root: Path) -> ConfigIdentity:
|
||||
if version == "unknown":
|
||||
m = _VERSION_TAG.search(props)
|
||||
if m:
|
||||
version = m.group(1).strip()
|
||||
version = _sanitize_text(m.group(1)) or "unknown"
|
||||
|
||||
m = _NAME_TAG.search(props)
|
||||
if m:
|
||||
name = m.group(1).strip() or None
|
||||
name = _sanitize_text(m.group(1)) or None
|
||||
|
||||
m = _SYN_RE.search(props)
|
||||
if m:
|
||||
synonym = _xml_unescape(m.group(1).strip()) or None
|
||||
synonym = _sanitize_text(_xml_unescape(m.group(1))) or None
|
||||
|
||||
m = _VENDOR_TAG.search(props)
|
||||
if m:
|
||||
vendor = _xml_unescape(m.group(1).strip()) or None
|
||||
vendor = _sanitize_text(_xml_unescape(m.group(1))) or None
|
||||
|
||||
return ConfigIdentity(
|
||||
version=version or "unknown",
|
||||
version=_sanitize_text(version) or "unknown",
|
||||
name=name,
|
||||
synonym=synonym,
|
||||
vendor=vendor,
|
||||
|
||||
Reference in New Issue
Block a user