Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions installer/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -1013,13 +1024,18 @@ 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
if not Path(binary).is_file():
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):
Expand Down
2 changes: 2 additions & 0 deletions tools/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down