ZaStoGram_desktop/Telegram/SourceFiles/tests/test_zastogram_branding.py
loop-uh 64b6f834b3
All checks were successful
Desktop source guards / guards (push) Successful in 7s
Ссылка «ZaStoGram» в меню — на рабочее зеркало git
git.zapret.moe в России блокируют по имени. Название программы внизу
главного меню вело прямо на https://git2.zapret.moe/…/releases; теперь оно
берёт Application::changelogLink(), который ставит ссылку на зеркало,
открывшееся у пользователя (ZsgMirrors). Тест брендинга запрещает прямую
ссылку на заблокированное имя в меню.

.gitmodules (lib_ui, lib_lottie), metainfo и ссылки генератора списка
изменений переведены на git2.zapret.moe; upstream-sync узнаёт форки
подмодулей по любому имени нашего git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 16:50:01 -04:00

104 lines
3.7 KiB
Python

#!/usr/bin/env python3
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
FORK_RELEASES = "https://git2.zapret.moe/zastogram/ZaStoGram_desktop/releases"
def source(path: str) -> str:
return (ROOT / path).read_text(encoding="utf-8")
def require(path: str, *needles: str) -> None:
text = source(path)
missing = [needle for needle in needles if needle not in text]
if missing:
raise AssertionError(
f"{path} lost ZaStoGram fork markers: {', '.join(missing)}")
def main() -> None:
application = source("SourceFiles/core/application.cpp")
if FORK_RELEASES not in application:
raise AssertionError("the ZaStoGram release history URL is missing")
require(
"SourceFiles/core/version.h",
'constexpr auto AppName = "ZaStoGram"_cs;',
"constexpr auto AppBetaVersion = false;",
)
require(
"SourceFiles/core/launcher.cpp",
'QApplication::setApplicationName(u"ZaStoGram"_q);',
)
require(
"SourceFiles/boxes/about_box.cpp",
"box->setTitle(AppName.utf16());",
'u" (build %1)"_q.arg(ZsgBuildId.utf16())',
)
require(
"SourceFiles/core/update_checker.cpp",
"kZaStoGramReleasesApi",
"https://git2.zapret.moe/api/v1/repos/",
"?draft=false&pre-release=true&limit=1",
"if (IsZaStoGramDevBuild())",
"ResponseType::DevReleases",
'release.value("prerelease").toBool()',
"ZaStoGramDevBuildNumber()",
'name == "current4"',
"_dev%2",
"versionNum == AppVersion && !IsZaStoGramDevBuild()",
"request.setTransferTimeout(int(kUpdateCheckTimeout));",
"tryLoaders();",
)
updater = source("SourceFiles/core/update_checker.cpp")
timeout = updater.split("void Updater::handleTimeout()", 1)[1].split(
"bool Updater::tryLoaders()", 1
)[0]
if "cSetLastUpdateCheck(0)" in timeout or "_timer.callOnce" in timeout:
raise AssertionError("a timed-out update check must not restart itself")
require(
"SourceFiles/window/window_main_menu.cpp",
"AppName.utf16()",
"Core::App().changelogLink()",
)
# git.zapret.moe is dropped by name in Russia: browser links go through
# Application::changelogLink(), which puts them on a working mirror.
if "https://git2.zapret.moe" in source("SourceFiles/window/window_main_menu.cpp"):
raise AssertionError("the main menu links the blocked git name directly")
require(
"SourceFiles/settings/sections/settings_advanced.cpp",
"BuildUpdateSection(builder, true);",
"return !downloading;",
"Core::UpdateChecker checker;",
"tr::lng_settings_check_now()",
)
advanced = source("SourceFiles/settings/sections/settings_advanced.cpp")
if "lng_settings_install_beta" in advanced:
raise AssertionError("the obsolete upstream beta switch returned")
require(
"SourceFiles/core/launcher.cpp",
"ZaStoGram has two baked, independent channels",
"cSetInstallBetaVersion(false);",
)
localstorage = source("SourceFiles/storage/localstorage.cpp")
if FORK_RELEASES + "/download/latest" not in localstorage:
raise AssertionError("the native Forgejo latest-asset prefix is missing")
if FORK_RELEASES + "/latest/download" in localstorage:
raise AssertionError("the GitHub latest-asset path order returned")
require(
"Resources/winrc/Telegram.rc",
'VALUE "FileDescription", "ZaStoGram"',
'VALUE "ProductName", "ZaStoGram"',
)
require(
"../.forgejo/workflows/source-guards.yml",
"release_guards.txt",
"Run canonical release source guards",
)
if __name__ == "__main__":
main()