fix: 通用项目以 App 字段作为产物文件名和通知中的 App 标识

通用项目(如朵云轩)没有 AppGuid,通知中 App Guid 为空、产物文件名以 _ 开头。
改为取第一个 App 字段(如 APPID)作为 App 标识,并在通知中显示该字段名;
未填写时回退到 upload_key。Readoor 项目不变。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-23 11:02:28 +09:00
co-authored by Claude Opus 5.5
parent 6890f13aa9
commit 9c0b677d38
4 changed files with 56 additions and 4 deletions
+35 -1
View File
@@ -350,7 +350,41 @@ async def test_generate_config(tmp_path, log_streamer):
assert saved["APPID"] == "guid-123"
def test_resolve_provisioning_profile_extracts_name_and_team(tmp_path):
@pytest.mark.parametrize("app_fields, appid, expected_id, expected_label", [
([{"key": "APPID", "label": "APPID"}], "1587365345", "1587365345", "APPID"),
([{"key": "APPID", "label": "APPID"}], "", "dy_app", "App 标识"),
([], "", "dy_app", "App 标识"),
])
async def test_generate_config_generic_project_identifier(
tmp_path, log_streamer, app_fields, appid, expected_id, expected_label,
):
"""通用项目没有 AppGuid,以第一个 App 字段作为产物文件名和通知中的 App 标识"""
build_dir = tmp_path / "build"
build_dir.mkdir()
task = MagicMock()
task.project_id = "dyauction"
task.app_id = "1"
task.scheme_id = "1"
task.build_type = "Ad_Hoc"
task.obfuscation = False
mock_config = {
"patcher": "generic",
"app_fields": app_fields,
"apps": {"1": {"name": "朵云轩", "server": "正式环境", "APPID": appid, "upload_key": "dy_app",
"certificates": {}}},
"schemes": {"1": {"name": "DyAuction", "ossFloder": "dy"}},
}
with patch("backend.routers.config.load_config", return_value=mock_config):
result = await generate_config("t1", task, build_dir)
assert result["APPID"] == expected_id
assert result["APPID_LABEL"] == expected_label
profile_path = tmp_path / "profile.mobileprovision"
profile_path.write_bytes(b"signed profile")
decoded = plistlib.dumps({"Name": "a4YX061_adHoc", "TeamIdentifier": ["MG4Z7FU83W"]})
+12 -1
View File
@@ -35,7 +35,18 @@ def test_dingtalk_payload_matches_autopacking_content():
assert "![image](https://download.example.com/app.png)" in text
def test_dingtalk_payload_at_mobiles_appended_to_text_and_at_field():
def test_dingtalk_payload_uses_project_identifier_label():
payload = build_dingtalk_payload(
{**_build_config(), "APPID": "1587365345", "APPID_LABEL": "APPID"},
"https://download.example.com/app.html",
)
text = payload["markdown"]["text"]
assert "**APPID:** 1587365345" in text
assert "App Guid" not in text
payload = build_dingtalk_payload(
_build_config(),
"https://download.example.com/app.html",