Preserve local OnePlus corrections after sync
This commit is contained in:
@@ -23,6 +23,41 @@ SYNC_PATHS = [
|
||||
"LICENSE.txt",
|
||||
]
|
||||
|
||||
LOCAL_TEXT_REPLACEMENTS = {
|
||||
"brands/oneplus.md": [
|
||||
(
|
||||
"""**一加 Ace 3 / 一加 12R (`aston`) / 一加 Ace 3 原神刻晴定制机 / 一加 12R Genshin Impact Edition (`martin`):**
|
||||
|
||||
`PJE110`: 一加 Ace 3 国行版 / 原神刻晴定制机
|
||||
|
||||
`CPH2585`: 一加 12R 印度版 / 原神刻晴定制机""",
|
||||
"""**一加 Ace 3 (`aston`):**
|
||||
|
||||
`PJE110`: 一加 Ace 3 国行版 / 原神刻晴定制机
|
||||
|
||||
**一加 12R (`aston`):**
|
||||
|
||||
`CPH2585`: 一加 12R 印度版 / 原神刻晴定制机""",
|
||||
),
|
||||
],
|
||||
"brands/oneplus_en.md": [
|
||||
(
|
||||
"""**OnePlus Ace 3 / OnePlus 12R (`aston`) / OnePlus Ace 3 Genshin Impact Edition / OnePlus 12R Genshin Impact Edition (`martin`):**
|
||||
|
||||
`PJE110`: OnePlus Ace 3 China / Genshin Impact Edition
|
||||
|
||||
`CPH2585`: OnePlus 12R India / Genshin Impact Edition""",
|
||||
"""**OnePlus Ace 3 (`aston`):**
|
||||
|
||||
`PJE110`: OnePlus Ace 3 China / Genshin Impact Edition
|
||||
|
||||
**OnePlus 12R (`aston`):**
|
||||
|
||||
`CPH2585`: OnePlus 12R India / Genshin Impact Edition""",
|
||||
),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def run(cmd: list[str], cwd: Path | None = None) -> None:
|
||||
subprocess.run(cmd, cwd=cwd or PROJECT_ROOT, check=True)
|
||||
@@ -62,6 +97,21 @@ def sync_selected_paths(upstream_root: Path) -> None:
|
||||
raise FileNotFoundError(f"Missing upstream path: {relative_path}")
|
||||
sync_path(src, dst)
|
||||
|
||||
apply_local_corrections()
|
||||
|
||||
|
||||
def apply_local_corrections() -> None:
|
||||
for relative_path, replacements in LOCAL_TEXT_REPLACEMENTS.items():
|
||||
path = WORKSPACE_ROOT / relative_path
|
||||
if not path.exists():
|
||||
continue
|
||||
text = path.read_text(encoding="utf-8")
|
||||
updated = text
|
||||
for old, new in replacements:
|
||||
updated = updated.replace(old, new)
|
||||
if updated != text:
|
||||
path.write_text(updated, encoding="utf-8")
|
||||
|
||||
|
||||
def build_index(output_path: str) -> None:
|
||||
run(
|
||||
|
||||
Reference in New Issue
Block a user