branch: externals/hyperbole
commit bee721f57492981da793f636c04bafbcb8d6b214
Merge: 659494d518e d8b2a4cb3e0
Author: bw <[email protected]>
Commit: bw <[email protected]>

    Merge branch 'master' into rsw
---
 ChangeLog                  | 15 ++++++++
 hypb-release.el            | 90 +++++++++++++++++++++++++++++-----------------
 man/hyperbole.texi         | 10 +++---
 test/MANIFEST              |  1 +
 test/hy-test-helpers.el    |  8 ++++-
 test/hypb-release-tests.el | 62 ++++++++++++++++++++++++++++++++
 6 files changed, 148 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 277f2212538..634608a5aed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -100,6 +100,21 @@
 
 2026-10-16  Mats Lidell  <[email protected]>
 
+* hypb-release.el (hypb-release-version-file-list): Rename variable as
+it is now a list of lists.
+(hypb-release--replace-version): Replaces the version number based on
+a given pattern
+(hypb-release-update-version): Use hypb-release-update-version.
+(hypb-release-update-hyperbole-version-header): Add pattern.
+
+* test/MANIFEST: Add hypb-release-tests.el.
+
+* test/hypb-release-tests.el: New test file for hypb-release.el.
+(hypb-release-tests--replace-version):
+(hypb-release-tests--update-version): Test cases.
+
+* man/hyperbole.texi: Use EDITION and VERSION variables.
+
 * Makefile (release-pre): Use remote for fetching and creating release
     branch. Use underscore in branch name.
 
diff --git a/hypb-release.el b/hypb-release.el
index 32a49287bd2..2262f43eaf8 100644
--- a/hypb-release.el
+++ b/hypb-release.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:     5-Oct-26 at 21:58:13
-;; Last-Mod:     14-Oct-26 at 13:49:08 by Bob Weiner
+;; Last-Mod:     16-Oct-26 at 22:03:31 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -18,21 +18,40 @@
 ;;; Code:
 
 (require 'lisp-mnt)
+(require 'cl-lib)
 
-(defvar hypb-release-version-files
-  '("hversion.el"
-    "HY-ABOUT"
-    "HY-ANNOUNCE"
-    "HY-NEWS"
-    "hyperbole-pkg.el"
-    "Makefile"
-    "README.in.md"
-    "man/hyperbole.texi")
+(defvar hypb-release-version-file-list
+  '(("hversion.el" "(defconst hyperb:version \"{version}\"")
+    ("HY-ABOUT" "Version {version}")
+    ("HY-ANNOUNCE" "Subject: GNU Hyperbole Major Release 9 (V{version})")
+    ("hyperbole-pkg.el" "{version}" t)
+    ("Makefile" "HYPB_VERSION = {version}")
+    ("README.in.md" "# GNU Hyperbole {version} - The Everyday Hypertextual 
Information Manager")
+    ("man/hyperbole.texi" "@set EDITION {version}")
+    ("man/hyperbole.texi" "@set VERSION {version}"))
   "Files in which the Hyperbole version number is stored.
-The list does not include hyperbole.el since that needs to be updated in
-the last commit for a release.  That update is controlled by a make
-target.  See also `hypb-release-update-hyperbole-version-header'.")
+Each list item contains the filename, a pattern for locating the version
+number and an optional flag that if non-nil means the file is not
+required to exist.  Note that the list does not include hyperbole.el
+since that needs to be updated in the last commit for a release.  That
+update is controlled by a make target.  See also
+`hypb-release-update-hyperbole-version-header'.")
 
+(defun hypb-release--replace-version (pattern old-version new-version 
&optional check)
+  "Replace OLD-VERSION with NEW-VERSION using PATTERN.
+PATTERN contains the placeholder {version}.  When CHECK is non-nil, only
+check that the pattern matches.  Return non-nil if the pattern was
+found."
+  (save-excursion
+    (goto-char (point-min))
+    (let ((search (string-replace "{version}" old-version pattern))
+          (replacement (string-replace "{version}" new-version pattern)))
+      (when (search-forward search nil t)
+        (unless check
+          (replace-match replacement t t))
+        t))))
+
+;;;###autoload
 (defun hypb-release-update-version (new-version)
   "Replace old-version with NEW-VERSION in `hypb-release-version-files'.
 
@@ -47,35 +66,42 @@ Files are saved normally by Emacs, so hooks are applied as 
if edited manually."
 
   (let ((old-version (lm-version "hyperbole.el")))
     ;; Check all files before any action.
-    (dolist (file hypb-release-version-files)
-      (unless (file-exists-p file)
-        (error "File does not exist: %s" file))
-      (with-temp-buffer
-        (insert-file-contents file)
-        (unless (search-forward old-version nil t)
-          (error "Version %s not found in %s"
-                 old-version file))))
+    (dolist (v hypb-release-version-file-list)
+      (let ((file (nth 0 v))
+            (pattern (nth 1 v))
+            (optional (nth 2 v)))
+        (unless (or optional (file-exists-p file))
+          (error "File does not exist: %s" file))
+        (when (file-exists-p file)
+          (with-temp-buffer
+            (insert-file-contents file)
+            (unless (hypb-release--replace-version pattern old-version 
new-version 'dry-run)
+              (error "Version %s not found in %s"
+                     old-version file))))))
 
     ;; Substitute and save all.
-    (let ((replacements 0))
-      (dolist (file hypb-release-version-files)
-        (with-current-buffer (find-file-noselect file)
-          (save-excursion
-            (goto-char (point-min))
-            (while (search-forward old-version nil t)
-              (replace-match new-version t t)
-              (setq replacements (1+ replacements))))
-          (save-buffer)))
+    (let ((replacements 0)
+          (files))
+      (dolist (v hypb-release-version-file-list)
+        (let ((file (nth 0 v))
+              (pattern (nth 1 v)))
+          (when (file-exists-p file)
+            (with-current-buffer (find-file-noselect file)
+              (unless (hypb-release--replace-version pattern old-version 
new-version)
+                (error "Version %s not found in %s" old-version file))
+              (setq replacements (1+ replacements))
+              (cl-pushnew file files :test 'equal)
+              (save-buffer)))))
 
       (message "Version %s -> %s: %d replacements in %d files"
                old-version new-version
-               replacements (length hypb-release-version-files)))))
+               replacements (length files)))))
 
 (defun hypb-release-update-hyperbole-version-header (new-version)
   "Update the version header in hyperbole.el to NEW-VERSION.
 This update needs to be in the last commit for a release and is run by a
 Makefile target."
-  (let ((hypb-release-version-files '("hyperbole.el")))
+  (let ((hypb-release-version-file-list '("hyperbole.el" ";; Version:      
{version}")))
     (hypb-release-update-version new-version)))
 
 (provide 'hypb-release)
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 30da20c8c89..339a5f128c1 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7,7 +7,7 @@
 @c Author:       Bob Weiner
 @c
 @c Orig-Date:     6-Nov-91 at 11:18:03
-@c Last-Mod:     17-Oct-26 at 23:02:18 by Bob Weiner
+@c Last-Mod:     18-Oct-26 at 09:47:54 by Bob Weiner
 
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename hyperbole.info
@@ -30,7 +30,7 @@
 @set txicodequoteundirected
 @set txicodequotebacktick
 
-@set UPDATED October 17, 2026
+@set UPDATED October 18, 2026
 @set UPDATED-MONTH October 2026
 @set EDITION 9.3.0
 @set VERSION 9.3.0
@@ -171,7 +171,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P>
 
 <PRE>
 Edition 9.3.0
-Printed October 17, 2026.
+Printed October 18, 2026.
 
   Published by the Free Software Foundation, Inc.
   Author:    Bob Weiner
@@ -213,7 +213,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 @example
 Edition 9.3.0
-October 17, 2026 @c AUTO-REPLACE-ON-SAVE
+October 18, 2026 @c AUTO-REPLACE-ON-SAVE
 
 
   Published by the Free Software Foundation, Inc.
@@ -558,7 +558,7 @@ Smart Keyboard Keys
 @chapter Introduction
 
 This edition of the GNU Hyperbole Manual is for use with any version
-9.3.0 or greater of GNU Hyperbole.  Hyperbole runs atop GNU Emacs
+@value{VERSION} or greater of GNU Hyperbole.  Hyperbole runs atop GNU Emacs
 28 or higher.  It will trigger an error if your Emacs is older.
 
 This chapter summarizes the structure of the rest of the manual,
diff --git a/test/MANIFEST b/test/MANIFEST
index d4f5c313c76..8ea6ef6625e 100644
--- a/test/MANIFEST
+++ b/test/MANIFEST
@@ -26,6 +26,7 @@ hy-test-dependencies.el - Hyperbole test dependencies
 hy-test-helpers.el      - unit test helpers
 hycontrol-tests.el      - hycontrol unit tests
 hypb-ert-tests.el       - hypb-ert tests
+hypb-release-tests.el   - tests for hypb-release
 hypb-tests.el           - tests for hypb.el utility functions
 hyperbole-tests.el      - tests for hyperbole.el
 hyrolo-tests.el         - unit tests for hyrolo.el
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index 79f1542c113..85485623c32 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <[email protected]>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     17-Aug-26 at 15:20:00 by Bob Weiner
+;; Last-Mod:     16-Oct-26 at 18:42:29 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -176,5 +176,11 @@ and the default WORD-LENGTH is 4."
                     (funcall orig-featurep f subfeature)))))
        ,@body)))
 
+(defun hy-test-file-contents (file)
+  "Return FILE contents as a string."
+  (with-temp-buffer
+    (insert-file-contents file)
+    (buffer-string)))
+
 (provide 'hy-test-helpers)
 ;;; hy-test-helpers.el ends here
diff --git a/test/hypb-release-tests.el b/test/hypb-release-tests.el
new file mode 100644
index 00000000000..0469f024fc9
--- /dev/null
+++ b/test/hypb-release-tests.el
@@ -0,0 +1,62 @@
+;;; hypb-release-tests.el --- unit tests for hypb-release -*- lexical-binding: 
t; -*-
+;;
+;; Author:       Mats Lidell
+;;
+;; Orig-Date:    16-Oct-26 at 18:32:18
+;; Last-Mod:     16-Oct-26 at 19:33:26 by Mats Lidell
+;;
+;; SPDX-License-Identifier: GPL-3.0-or-later
+;;
+;; Copyright (C) 2026  Free Software Foundation, Inc.
+;; See the "../HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+;;
+
+;;; Code:
+
+(require 'ert)
+(require 'ert-x)
+(require 'el-mock)
+(require 'hy-test-helpers)
+(require 'hypb-release)
+
+(ert-deftest hypb-release-tests--replace-version ()
+  "Test `hypb-release--replace-version'."
+  (with-temp-buffer
+    (insert "Version: 1.0")
+    (should-not (hypb-release--replace-version "Version: {version}" "1.1" 
"1.2" 'dry-run))
+    (should (hypb-release--replace-version "Version: {version}" "1.0" "1.2" 
'dry-run))
+    (should (hypb-release--replace-version "Version: {version}" "1.0" "1.2"))
+    (should (string= "Version: 1.2" (buffer-string)))))
+
+(ert-deftest hypb-release-tests--update-version ()
+  "Test `hypb-release-update-version'."
+  (let* ((file1 (make-temp-file "hypb" nil nil "Version: 1.0"))
+         (file2 (make-temp-file "hypb" nil nil "Version: 1.0 V1.0"))
+         (hypb-release-version-file-list
+          (list (list file1 "Version: {version}")
+                (list file2 "Version: {version}")
+                (list file2 "V{version}")
+                (list "no-such-file" "Version: {version}" t))))
+    (unwind-protect
+        (mocklet (((lm-version "hyperbole.el") => "1.0"))
+          (ert-with-message-capture cap
+            (hypb-release-update-version "1.1")
+            (hy-test-helpers:should-last-message
+             "Version 1.0 -> 1.1: 3 replacements in 2 files" cap))
+          (should (string-prefix-p "Version: 1.1" (hy-test-file-contents 
file1)))
+          (should (string-prefix-p "Version: 1.1 V1.1" (hy-test-file-contents 
file2))))
+      (hy-delete-files-and-buffers (list file1 file2)))))
+
+;; This file can't be byte-compiled without the `el-mock' package
+;; which is not a dependency of Hyperbole.
+;;
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
+
+(provide 'hypb-release-tests)
+;;; hypb-release-tests.el ends here

Reply via email to