From e03b29983afa645f18ecbc7f6dae7f5f64a3e6a0 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 24 May 2026 03:46:37 -0500 Subject: [PATCH] fix: updates_xml_build preserves existing channel entries When building a dev release, the CLI was overwriting the entire updates.xml with only the dev entry, wiping the stable channel. Now reads existing entries and preserves channels not being updated. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- cli/updates_xml_build.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cli/updates_xml_build.php b/cli/updates_xml_build.php index bfebc69..76ba235 100644 --- a/cli/updates_xml_build.php +++ b/cli/updates_xml_build.php @@ -316,6 +316,32 @@ for ($i = 0; $i <= $stabilityIndex; $i++) { ); } +// -- Preserve existing entries for channels not being updated ----------------- +$dest = $outputFile ?? "{$root}/updates.xml"; +$preservedEntries = []; + +if (file_exists($dest)) { + $existingXml = @simplexml_load_file($dest); + if ($existingXml) { + // Channels we're writing — don't preserve these + $writtenChannels = []; + for ($i = 0; $i <= $stabilityIndex; $i++) { + $writtenChannels[] = $allChannels[$i]; + } + + foreach ($existingXml->update as $existingUpdate) { + $existingTag = ''; + if (isset($existingUpdate->tags->tag)) { + $existingTag = (string) $existingUpdate->tags->tag; + } + // Keep entries for channels we're NOT overwriting + if (!empty($existingTag) && !in_array($existingTag, $writtenChannels, true)) { + $preservedEntries[] = ' ' . trim($existingUpdate->asXML()); + } + } + } +} + // -- Write updates.xml -------------------------------------------------------- $year = date('Y'); $output = << XML; -$output .= "\n" . implode("\n", $entries) . "\n\n"; +$allEntries = array_merge($preservedEntries, $entries); +$output .= "\n" . implode("\n", $allEntries) . "\n\n"; $dest = $outputFile ?? "{$root}/updates.xml"; file_put_contents($dest, $output);