diff --git a/installer/setup.py b/installer/setup.py index 34c3455..85167ce 100644 --- a/installer/setup.py +++ b/installer/setup.py @@ -992,12 +992,23 @@ def halloy_test_write_launcher(binary, icon=None, home=None): return exe +def woggle_config_dir(name="woggle"): + if os.name == "nt": + return Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") / name + return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / name + + +def woggle_reads_halloy_folder(tag): + """Woggle releases before v1.2.0 read their config from the halloy folder.""" + m = re.match(r"v?(\d+)\.(\d+)(?:\.(\d+))?", tag or "") + if not m: + return False + return tuple(int(x or 0) for x in m.groups()) < (1, 2, 0) + + def halloy_test_write_config(files, settings, cfg_dir=None): if not cfg_dir: - if os.name == "nt": - cfg_dir = Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") / "woggle" - else: - cfg_dir = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "woggle" + cfg_dir = woggle_config_dir() cfg_dir = Path(cfg_dir) client = Client("halloy", "Woggle", cfg_dir, "halloy") install(client, files, settings) @@ -1013,6 +1024,7 @@ def install_halloy_test(files, settings, log): if not halloy_test_has_access(): raise HalloyTestError("halloy_test_noaccess") got = halloy_test_from_release(log) + from_release = got is not None if got is None: got = halloy_test_from_source(log) binary, icon = got @@ -1020,6 +1032,10 @@ def install_halloy_test(files, settings, log): raise HalloyTestError("halloy_test_failed", e="binary not found") halloy_test_write_launcher(binary, icon) halloy_test_write_config(files, settings) + # NO: Woggle før v1.2.0 leser fortsatt halloy-mappen, så den får samme oppsett der. + # EN: Woggle before v1.2.0 still reads the halloy folder, so it gets the same setup there. + if from_release and woggle_reads_halloy_folder(halloy_test_latest_tag()): + halloy_test_write_config(files, settings, woggle_config_dir("halloy")) def fmt_menu(lang, key): diff --git a/tools/test_clients.py b/tools/test_clients.py index d6415e1..5d6dac1 100644 --- a/tools/test_clients.py +++ b/tools/test_clients.py @@ -358,6 +358,8 @@ def test_installer(): setup.halloy_test_write_config(files, {"ircop": False, "lang": "no", "autoreply": True}) check("woggle config goes to woggle folder", (wdir / "config.toml").exists(), True) check("woggle install leaves halloy folder alone", (cfg_home / "halloy").exists(), False) + for tag, want in (("v1.1.0", True), ("v1.0.0", True), ("v1.2.0", False), ("v1.10.0", False), ("", False), ("nightly", False)): + check("woggle " + (tag or "no tag") + " reads halloy folder", setup.woggle_reads_halloy_folder(tag), want) check("woggle config keeps existing settings", tomllib.loads((wdir / "config.toml").read_text(encoding="utf-8")).get("servers", {}).get("scoutlink") is not None, True) finally: