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:
co-authored by
Claude Opus 5.5
parent
6890f13aa9
commit
9c0b677d38
@@ -20,7 +20,7 @@ from ..config import (
|
||||
get_git_remote_url,
|
||||
mask_git_remote_url,
|
||||
)
|
||||
from ..projects import LEGACY_PROJECT_ID, get_definition, get_project_source
|
||||
from ..projects import LEGACY_PROJECT_ID, PATCHER_READOOR, get_definition, get_project_source
|
||||
from .log_streamer import log_streamer
|
||||
from .distribution import DistributionError, publish_dsym, publish_ipa
|
||||
from .notification import NotificationError, send_dingtalk_notification
|
||||
@@ -808,6 +808,13 @@ async def generate_config(task_id: str, task, build_dir: Path) -> dict:
|
||||
config_data["APP_VARS"] = {
|
||||
field["key"]: app.get(field["key"], "") for field in definition["app_fields"] if field.get("key")
|
||||
}
|
||||
# 通用项目没有 AppGuid:以第一个 App 字段(如 APPID)作为 App 标识,
|
||||
# 用于产物文件名和通知;未配置 App 字段时用 upload_key。
|
||||
if definition["patcher"] != PATCHER_READOOR:
|
||||
id_field = next((field for field in definition["app_fields"] if field.get("key")), None)
|
||||
app_ident = config_data["APP_VARS"].get(id_field["key"], "") if id_field else ""
|
||||
config_data["APPID"] = app_ident or config_data["UPLOAD_KEY"]
|
||||
config_data["APPID_LABEL"] = (id_field.get("label") or id_field["key"]) if app_ident else "App 标识"
|
||||
config_data["SERVER_VARS"] = {
|
||||
field["key"]: server.get(field["key"], "") for field in definition["server_fields"] if field.get("key")
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ def build_dingtalk_payload(
|
||||
f"**版本:** {config_data.get('VERSION', '')}\n\n"
|
||||
f"**APP名称:** {config_data.get('APPID_NAME', '')}\n\n"
|
||||
f"**包名:** {config_data.get('BUNDLE_ID', '')}\n\n"
|
||||
f"**App Guid:** {config_data.get('APPID', '')}"
|
||||
f"**{config_data.get('APPID_LABEL', 'App Guid')}:** {config_data.get('APPID', '')}"
|
||||
)
|
||||
text = f"## {heading}\n\n{details}\n\n**iOS 下载链接:** {download_url}\n"
|
||||
if qr_code_url:
|
||||
|
||||
@@ -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"]})
|
||||
|
||||
@@ -35,7 +35,18 @@ def test_dingtalk_payload_matches_autopacking_content():
|
||||
assert "" 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",
|
||||
|
||||
Reference in New Issue
Block a user