This commit is contained in:
@@ -72,8 +72,25 @@ def source(raw):
|
||||
}
|
||||
|
||||
|
||||
def comparable_description(text):
|
||||
"""Canonicalize empty platform placeholders only; preserve all substantive text.
|
||||
|
||||
This comparison key must never replace the reviewed text sent to the platform.
|
||||
Unknown or partially filled templates remain exact to protect concurrent edits.
|
||||
"""
|
||||
empty_template = r"\s*" + r"\s*".join(re.escape(heading.strip()) for heading in HEADINGS) + r"\s*"
|
||||
return "" if not text.strip() or re.fullmatch(empty_template, text) else text
|
||||
|
||||
|
||||
def fingerprint(value):
|
||||
return hashlib.sha256(json.dumps(value, sort_keys=True, ensure_ascii=False).encode()).hexdigest()
|
||||
comparable = {
|
||||
**value,
|
||||
"sections": {
|
||||
key: {**item, "description": comparable_description(item["description"])}
|
||||
for key, item in value["sections"].items()
|
||||
},
|
||||
}
|
||||
return hashlib.sha256(json.dumps(comparable, sort_keys=True, ensure_ascii=False).encode()).hexdigest()
|
||||
|
||||
|
||||
def parse_description(text):
|
||||
@@ -300,7 +317,10 @@ async def run_check(runner, job_id, payload):
|
||||
patch = {}
|
||||
for section, item in current["sections"].items():
|
||||
before, target = expected["sections"][section], payload["descriptions"][section]
|
||||
if item["code"] != before["code"] or item["description"] not in (before["description"], target):
|
||||
if item["code"] != before["code"] or comparable_description(item["description"]) not in (
|
||||
comparable_description(before["description"]),
|
||||
comparable_description(target),
|
||||
):
|
||||
raise WqError("平台表达式或 Description 已变化,未覆盖;请刷新后重新核对", "conflict")
|
||||
if item["description"] != target:
|
||||
patch[section] = {"description": target}
|
||||
|
||||
Reference in New Issue
Block a user