From 82b6875f5aac077f018c986d1d0529cfbf5e3bec Mon Sep 17 00:00:00 2001 From: tronyx Date: Wed, 11 Nov 2026 14:59:23 -0500 Subject: [PATCH 1/2] Put a blank line before the first check that --migrate writes render_migration joined the header lines and the check tables separately, so the first [[check]] came right after the last [hosts] or [auth.] line. Join them in one list, so every table follows a blank line. A test covers checks after the hosts and after an auth table. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 +++- healthchecks_linux.py | 2 +- tests/test_migrate.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 843c5cd..aef2825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,9 @@ The project doesn't use version numbers. Each entry is one merge into `master`, ## Unreleased -Nothing yet. +### Fixed + +- `--migrate` puts a blank line before the first `[[check]]` table in the file that it writes. Before, that table came right after the last line of `[hosts]` or of an `[auth.]` table. The file worked the same, but it was harder to read. ## 2026-11-10 · [#5](https://github.com/tronyx/HealthChecks-Linux/pull/5) diff --git a/healthchecks_linux.py b/healthchecks_linux.py index 6e6b64d..175e316 100755 --- a/healthchecks_linux.py +++ b/healthchecks_linux.py @@ -1132,7 +1132,7 @@ def render_migration(migration: Migration, source: Path) -> str: f"password = {_toml(credentials.password)}", "", ] - return "\n".join(lines) + "\n".join(migration.checks) + return "\n".join([*lines, *migration.checks]) def write_migrated_config(target: Path, text: str) -> None: diff --git a/tests/test_migrate.py b/tests/test_migrate.py index c5daf58..25e10d6 100644 --- a/tests/test_migrate.py +++ b/tests/test_migrate.py @@ -1,5 +1,6 @@ """Tests for --migrate: writing healthchecks.toml from a configured copy of the Bash script.""" +import itertools import stat from pathlib import Path @@ -186,6 +187,23 @@ def test_migrated_hosts(migrated: tuple[Path, str]) -> None: assert '[hosts]\ndomain = "example.test"\ndocker = "10.0.0.5"\nunifi_nvr = "10.0.0.6"\nempty = ""\n' in text +@pytest.mark.parametrize( + ("text", "has_auth"), + [(CONFIGURED, True), (CONFIGURED.replace(" check_nagios\n", ""), False)], + ids=["checks after the auth tables", "checks after the hosts"], +) +def test_migrated_tables_follow_a_blank_line(tmp_path: Path, text: str, has_auth: bool) -> None: + script = tmp_path / "application_healthchecks_generic.sh" + script.write_text(text, encoding="utf-8") + target = tmp_path / "healthchecks.toml" + assert main(["--migrate", str(script), "-c", str(target)], {}) == 0 + migrated = target.read_text(encoding="utf-8") + assert ("\n[auth." in migrated) is has_auth + lines = migrated.split("\n") + assert [line for before, line in itertools.pairwise(lines) if line.startswith("[") and before] == [] + assert migrated.endswith("]\n") + + def test_migration_report(migrated: tuple[Path, str]) -> None: out = migrated[1] for line in ( From a9556c5671920abcd4cb1e90d695cd97a466e552 Mon Sep 17 00:00:00 2001 From: tronyx Date: Wed, 11 Nov 2026 15:30:42 -0500 Subject: [PATCH 2/2] Move the changelog entries under #6 Also sets --version to the release date, 2026-11-11. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++++ healthchecks_linux.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aef2825..43d6059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The project doesn't use version numbers. Each entry is one merge into `master`, ## Unreleased +Nothing yet. + +## 2026-11-11 · [#6](https://github.com/tronyx/HealthChecks-Linux/pull/6) + ### Fixed - `--migrate` puts a blank line before the first `[[check]]` table in the file that it writes. Before, that table came right after the last line of `[hosts]` or of an `[auth.]` table. The file worked the same, but it was harder to read. diff --git a/healthchecks_linux.py b/healthchecks_linux.py index 175e316..c0c3d68 100755 --- a/healthchecks_linux.py +++ b/healthchecks_linux.py @@ -47,7 +47,7 @@ print(f"healthchecks-linux: Python 3.10 or newer is needed, but this is Python {_version}", file=sys.stderr) sys.exit(2) -__version__ = "2026-11-10" +__version__ = "2026-11-11" EXIT_OK = 0 EXIT_ERROR = 1