[polari] build: Also check NEWS for version



commit b3840f7570d92da67c518e50c47046f621c5930f
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 31 00:59:33 2021 +0200

    build: Also check NEWS for version
    
    Now that we added a check-version script, extend it to also allow
    for checking the NEWS file for the current version.
    
    Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/220>

 meson.build            |  3 +++
 meson/check-version.py | 18 ++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/meson.build b/meson.build
index 83cf8101..0111f4db 100644
--- a/meson.build
+++ b/meson.build
@@ -63,9 +63,12 @@ subdir('help')
 
 meson.add_install_script('meson/meson-postinstall.sh')
 
+meson.add_dist_script(check_version, meson.project_version(), 'NEWS')
+
 if (appstream_util.found())
   meson.add_dist_script(check_version,
     meson.project_version(),
+    '--type', 'metainfo',
     'data/appdata/org.gnome.Polari.appdata.xml.in')
 endif
 
diff --git a/meson/check-version.py b/meson/check-version.py
index d8c1ed81..81750c99 100755
--- a/meson/check-version.py
+++ b/meson/check-version.py
@@ -4,11 +4,21 @@ import os, sys
 from pathlib import Path
 import argparse, subprocess
 
-def check_version(version, file):
-    subprocess.run(['appstream-util', 'validate-version', file, version],
-                   check=True)
+def check_version(version, file, type='news'):
+    if type == 'news':
+        line = file.open().readline()
+        ok = line.startswith(version)
+        print("{}: {}".format(file, "OK" if ok else "FAILED"))
+        if not ok:
+            raise Exception("{} does not start with {}".format(file, version))
+    elif type == 'metainfo':
+        subprocess.run(['appstream-util', 'validate-version', file, version],
+                       check=True)
+    else:
+        raise Exception('Not implemented')
 
 parser = argparse.ArgumentParser(description='Check release version information.')
+parser.add_argument('--type', choices=['metainfo','news'], default='news')
 parser.add_argument('version', help='the version to check for')
 parser.add_argument('files', nargs='+', help='files to check')
 args = parser.parse_args()
@@ -17,6 +27,6 @@ distroot = os.environ.get('MESON_DIST_ROOT', './')
 
 try:
     for file in args.files:
-        check_version(args.version, Path(distroot, file))
+        check_version(args.version, Path(distroot, file), args.type)
 except:
     sys.exit(1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]